0

I have emojis stored in my database on my post titles, they are displayed correctly, like this The database field is encoded like this : UTF8-Unicode the Collation says : utf8mb4_unicode_ci

When I display the post_title, I don't see correctly the Emojis like on the database.

With a script I would like to explode the title by doing this, and it's not working $post_title_tab = explode("", $post_title);

I tried with utf8_decode and utf8_encode, not working...

Via
  • 77
  • 1
  • 9
  • 1
    Does this answer your question? [UTF-8 all the way through](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – gre_gor May 09 '20 at 10:58

1 Answers1

0

Your database charset may be set improperly, in order to store emojis (and other 4 bytes characters in databases such as mysql you need to use the charset utf8mb4).

If you're using mysql run the following query, it will convert your table's charset to the one required for emoji

ALTER TABLE YourTable CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
DannyM
  • 743
  • 6
  • 20
  • 1
    In fact the Encodage says : UTF-8 Unicode And the Collation says : utf8mb4_unicode_ci – Via May 09 '20 at 11:19