1
votes

I want to store emojis (android or iphone) in my mysql database, I tried many tutorials and SO posts, on the internet like :

How to insert utf-8 mb4 character(emoji in ios5) in mysql?

http://andy-carter.com/blog/saving-emoticons-unicode-from-twitter-to-a-mysql-database

MySQL utf8mb4, Errors when saving Emojis

I changed all things those tuts require. I have now the following mysql configuration :

character_set_client : utf8mb4

character_set_connection : utf8mb4

character_set_database : utf8mb4

character_set_filesystem : binary

character_set_results : utf8mb4

character_set_server : latin1

character_set_system :utf8

collation_connection : utf8mb4_unicode_ci

collation_database : utf8mb4_unicode_ci

collation_server : latin1_swedish_ci

But I can't still store 4 bits emojis on my mysql database, I have "????", which is pretty annoying.

Please help.

1
Your assumption is wrong. MySQL definitely saved it. You're pulling the info out and displaying it wrong. Since you didn't tell us what you're using to view those characters - all that's left is guessing around.Mjh
Thank you very much for answering me. Please, I use html tags and php tools (like echo) to display it on my website. Do you need please other informations ?kabrice
Your HTML page must be set to display utf8 correctly. Connection between PHP and MySQL must be set to utf8. You can find more info by googling about these topics, it's much better than me posting links here (there's also so many answers here at SO).Mjh
Thank you very much. I changed the meta tag to <meta charset="utf8mb4"> in my html page, but the problem is still there, I can't display emojis encoded in utf8mb4. Thxkabrice

1 Answers

2
votes

"4 bytes", not "4 bits".

The column/table needs to be CHARACTER SET utf8mb4.

<meta charset="UTF8">, not utf8mb4 -- This is talking to HTML, not MySQL. Outside of MySQL, the proper name is "UTF-8" or "UTF8"; utf8mb4 is a MySQL kludge.

See "question marks" in https://stackoverflow.com/a/38363567/1766831

Exactly 4 question marks implies that the column was not changed. Use ALTER TABLE ... CONVERT TO ...;