Ok so I got a web server serving UTF-16 jsons.
UTF-16 needed so don't even dare to answer "why don't you switch to UTF-8".
Apparently firefox can't read them.
In fact i get a JSON.parse error...
I tried switching to UTF-8 to prove that's the problem and it works...
but how can i make it successfully decode UTF-16?
my response headers charset is already "UTF-16"
The answer is you can't... Not with up to date versions of Firefox at least....
Related
In my Ruby/Rack app I have static characters from Chinese and Japanese, in the ruby code and HTML views. When I'm running my app, I get an exception:
Encoding::InvalidByteSequenceError at /
/my_app/index.html.erb is not valid US-ASCII
It happens only on a production server, on locally -- not.
My local machine -- Linux, remote server -- FreeBSD.
I've tried "save with encoding --> utf-8" but it didn't help.
I'm not using encode/decode function in ruby code -- those characters are just statically embedded in my files.
This might be a problem with String input encodings. Strings you receive via params for example.
I had to enforce the encoding to UTF-8 via:
"Some String".force_encoding("UTF-8")
which stopped the error messages.
I'm developing a webservice written in C and hosted by a RedHat 6.3 box. The box locale is fr_FR.UTF-8.
When I curl my webservice from the command line, I can read text content contaning accents on the command line.
However, when I check the WS output through the Chrome Developer tools and in the webpage output, the accents are replaced by a square containing an interrogation mark.
The content type of the webservice output is application/json; charset=utf-8.
The webpage charset is utf-8, browser is in autodetect.
What did I miss that unables me to properly display accents with utf-8 ?
I solved this by checking the way the accented content was generated. Actually mine was generated by Postgresql, whose configuration parameter client_encoding was set to ascii, un changed client_encoding to 'UTF8', thsi solved my issue.
My Firefox just did an update, and now all my XMLHttpRequest (that worked 10 minutes ago) answer in Chinese...
I can read this as responseText in firebug :
"㰿硭氠癥牳楯渽∱⸰∠敮捯摩湧㴢畴昭ㄶ∿㸍਼㽸浬瑹汥獨敥琠瑹灥㴧瑥硴⽸獬✠桲敦㴧⽯扩砯硳搧㼾ഊ㱯扪慭攽≷慴捨㌢牥昽≨瑴瀺⼯ㄲ㜮〮〮ㄺ㠰㠰⽯扩砯睡瑣桓敲癩捥⽷慴捨㌯∠楳㴢潢楸㩗慴捨∾ഊ†㱲敬瑩浥慭攽≬敡獥∠桲敦㴢汥慳支∠睲楴慢汥㴢瑲略∠癡氽≐吵䴢楮㴢偔こ∠⼾ഊ†㱩湴慭攽≡摤䙲敱略湣礢牥昽≡摤䙲敱略湣礯∠睲楴慢汥㴢瑲略∠癡氽∵〰∠浩渽∰∠⼾ഊ†㱯瀠湡浥㴢慤搢牥昽≡摤⼢渽≯扩砺坡瑣桉渢畴㴢潢楸㩗慴捨併琢 㸍ਠ‼潰慭攽≲敭潶攢牥昽≲敭潶支∠楮㴢潢楸㩗慴捨䥮∠潵琽≯扩砺乩氢 㸍ਠ‼潰慭攽≰潬汃桡湧敳∠桲敦㴢灯汬䍨慮来猯∠楮㴢潢楸㩎楬∠潵琽≯扩砺坡瑣桏畴∠⼾ഊ†㱯瀠湡浥㴢灯汬剥晲敳栢牥昽≰潬汒敦牥獨⼢渽≯扩砺乩氢畴㴢潢楸㩗慴捨併琢 㸍ਠ‼潰慭攽≤敬整攢牥昽≤敬整支∠楮㴢潢楸㩎楬∠潵琽≯扩砺乩氢 㸍ਠ‼潰慭攽≳瑡琢牥昽≳瑡琯∠楮㴢潢楸㩎楬∠潵琽≯扩砺坡瑣桓瑡琢 㸍਼⽯扪"
This is fun, but I really would like to have my real answer back.
Do you know if I can change a setting or something?
An important thing to know, is that my ajax code is a crossdomain request. Is it possible that something changed in the http header encoding ?
Thanx a lot !
Firefox now gives precedence to the UTF-16 BOM over HTTP. This is not a regression but an intentional change. Better not use a UTF-16 BOM if the bytes after it aren't UTF-16!
I have an element in a web page containing a UTF-8 encoded filename URL
<A HREF='http://server/site/%E8%A8%82%E8%B2%A8%E6%97%A5%E7%B5%90%E5%A4%B1%E6%95%97.txt'>訂貨日結失敗.txt</A>
This returns a 404 page from IIS. The file exists in the correct location on the server.
When I monitor what IIS is looking for using ProcMon, I can see it attempting to find a file that looks like the raw bytes from the UTF-8 string rather than the UTF-16 (?) string.
Ȩ‚Ȳ¨Æ—¥ÇµÅ¤±Æ•—.TXT
I'd have thought IIS would have done the UTF-8 to UTF-16 conversion to look for the filename on the server.
Any ideas where I'm going wrong.
Ta,
J
Looks like I need to use IIS 6 as a minimum. I've just tested it and it seems to work OK. msdn.microsoft.com/en-us/magazine/cc301710.aspx
I've written a bunch of xhr stuff over the years, but today I ran into a curious thing. In firefox with firebug every time my server responds, I get a syntax error in the console. And the error context is the message response text.
The message response text is a string of numbers separated by pipes "|".
Sure it's not valid xml, but I've never sent valid xml before and never had a problem.
Is this a firebug thing or is firefox really unhappy about my response text?
No. It can be xml, json, or some other structure of your choosing.