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.
Related
iam working on a large app built with sinatra 1.2, few days ago i upgraded sinatra gem to version 2.
after upgrading this error produce
Encoding::UndefinedConversionError - "\xD8" from ASCII-8BIT to UTF-8:
when pass param with arabic language like services/مواقع
i searched for it and i didn't found any soluation except force_encoding("UTF-8") that can't use it for all params in my app
can anyone help me on this? Thank you!
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....
I've found an issue when accessing to an URL related to special characters. The URL is generated in JS with many parameters. When the redirection is processed in IE10 the URL works fine. This is the parameter with the special character and that causes the problem:
nacional=Espa%C3%B1a
but when the same process is executed in IE11 the same parameter looks like this. As you can see it is not encoded in UTF-8
nacional=España
I've tried to change in IE the encoding and the UTF-8 link properties and it didn't work.
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.
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