Putting Unicode characters in JSON
On Fri, 23 Mar 2018 07:09:50 +1100, Chris Angelico wrote:
>> I was reading though, that JSON files must be encoded with UTF-8. So
>> should I be doing string.decode('latin-1').encode('utf-8')? Or does
>> the json module do that for me when I give it a unicode object?
> Reconfigure your MySQL database to use UTF-8. There is no reason to use
> Latin-1 in the database.
You don't know that. You don't know what technical, compatibility, policy
or historical constraints are on the database.
> If that isn't an option, make sure your JSON files are pure ASCII, which
> is the common subset of UTF-8 and Latin-1.
And that's utterly unnecessary, since any character which can be stored
in the Latin-1 MySQL database can be stored in the Unicode JSON.