In Ruby, I have a bunch of strings encoded in UTF-8, e.g.: “HEC Montr\u00e9al”.
When I insert it into my MySQL table (formatted as utf8_general_ci) using the ‘mysql’ gem, the backslash is removed. What gives 🙂 ? Any of you have any idea what the heck is going on here?
edit:
example string:
>> p mystring
"HEC Montr\\u00e9al"
and in the database after insert:
HEC Montru00e9al
This is not UTF:
That’s an ASCII representation of a JSON-encoded Unicode string. If it was UTF-8, it would look like:
You’re not properly decoding your JSON inputs somewhere or your client-side code is sending your server JSON when your server is expecting plain text.
First you need to figure out why you’re getting JSON encoded strings when you’re not expecting them or figure out why you’re not properly decoding your JSON. Then you can see if the database is mangling your UTF-8.