Post

To store emojis in MariaDB/MySQL for an existing table using the default/bad collation: ALTER TABLE your_table_name CONVERT TO character set utf8mb4 collate utf8mb4_unicode_ci; In Django's settings .py: 'OPTIONS': { 'charset': 'utf8mb4', } NOTE: collation name and charset are slightly different.

I had changed my DB settings in django's settings to support emojis, but forgot I had already built some tables using the bad/default charset/collation... It's sometimes easier to change the DB (main) instead of using migrations, if it's just a table that snuck through w/out the right charset.

That MariaDB/MySQL still uses a 3-byte partial-unicode character encoding by default is pretty annoying. I saw emojis in user inputs breaking w/ exceptions: (1366, "Incorrect string value: '\\\\xF0\\\\x9F\\\\x99\\\\x83\\\\xF0\\\\x9F...' for column `blah`.`blah_table`.`body` at row 1")

0 reposts0 likes

No replies yet.