[Answered ]-How to predict error when saving utf8 chars in latin-1 mysql table via django?

1👍

Go to the "mysql" commandline tool. Use it to do SHOW CREATE TABLE tablename; That will tell you the charsets (and collations) for the columns of that table.

SET NAMES latin1; declares that the client encoding is latin1, not cp1252, not UTF-8, etc.

\x93na\xefve\x97T-cells\x94 is the cp1256 or latin1 for “naïve—T-cells”. Hence, the SET should have helped.

latin1 hex:       936E61EF766597542D63656C6C7394
utf8 hex:         E2809C6E61C3AF7665E28094542D63656C6C73E2809D
'double-encoded': C3A2E282ACC5936E61C383C2AF7665C3A2E282ACE2809D542D63656C6C73C3A2E282ACC29D

(My answer in the link was referring to "double encoding" in item 7.)

E289A5 is utf8 for `≥`, which _cannot_ be properly encoded in latin1.

So, if you are seeing in the client, then it is not latin1, and some of the things in your Question need further investigation. Here are then encodings where it will work.

                    binary, utf8mb4, utf8  E289A5
                                    euckr  A1C3
                     gb18030, gb2312, gbk  A1DD
                                  keybcs2  F2
                             koi8r, koi8u  99
                          macce, macroman  B3

The bottom line, is that you should use UTF-8 (MySQL’s "utf8mb4") for everything.

Leave a comment