2

Sorry in advance if this is a it of a dim question, I'm good at basic SQL stuff, but by no means a professional and character encoding goes WAY over my head.

I've currently got a basic commenting system set up on a site with a basic form that submits the contents of a textarea box to a MySQL database and I thought it would be a good idea to see if I can get emoji functioning in case anyone tries to enter one.

I've changed the encoding of the table to utf8mb4, and changed the changed the charset my page uses when connecting to the database to utf8mb4 too.

But that's about where my understanding of this ends and it still doesn't work. At present, when an emoji is entered into the database, I get a string of characters like this (for the Jack O' Lantern emoji):

🎃

I have no idea what kind of encoding that is, to be honest! Anyone know where I'm going wrong? As I said, all this stuff goes over my head so don't feel bad about dumbing it down for me

bababababa
  • 87
  • 1
  • 5
  • The only tricky bit is using `utf8mb4` instead of `utf8`. Do regular UTF-8 chars like `€` or `Á` work? You need to use UTF-8 in your complete stack. – Álvaro González Nov 29 '20 at 14:13
  • No, looks like those characters don't work either! – bababababa Nov 29 '20 at 15:02
  • Does this answer your question? [How to store Emoji Character in MySQL Database](https://stackoverflow.com/questions/39463134/how-to-store-emoji-character-in-mysql-database) – Will B. Nov 29 '20 at 16:47
  • Well, then it isn't really an emoji problem. In whatever platform you're using, there's a step where you are relying on default encoding and it isn't UTF-8. Without further details it's impossible to say what you're missing. – Álvaro González Nov 29 '20 at 17:24
  • That's mojibake for -- See Mojibake in https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Nov 30 '20 at 04:54

1 Answers1

1

You have to change your character set to utf8mb4.

EDIT: Found a very similar topic here: How to store Emoji Character in MySQL Database

EDIT 2: See my code on DB FIDDLE : https://www.db-fiddle.com/f/jpyVfGoE7xi1Deigspiii7/0