Imported emoji in mysql table and json_encode

enter image description here

I copy MSSQL table to mysql table using (dbconvert.com)
All the emoji in the SQL SERVER ( טוב😄) set in mysql like that (טוב����).

It wasn’t a problem until I was trying to do json_encode to a query that include emoji in this text.

This is the code problem:

echo json_encode($forumPage);

Some things I had tryied

1) adding

    header('Content-Type: application/json; charset=utf-8');

2) using

   json_encode($forumPage,JSON_UNESCAPED_UNICODE);

3) using (this is WordPress site)

   define('DB_CHARSET', 'utf8mb4');

Some extra info about my DB:

   SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%' OR Variable_name LIKE 'collation%'
+--------------------------+--------------------+
| Variable_name            | Value              |
+--------------------------+--------------------+
| character_set_client     | utf8mb4            |
+--------------------------+--------------------+
| character_set_connection | utf8mb4            |
+--------------------------+--------------------+
| character_set_database   | utf8mb4            |
+--------------------------+--------------------+
| character_set_filesystem | binary             |
+--------------------------+--------------------+
| character_set_results    | utf8mb4            |
+--------------------------+--------------------+
| character_set_server     | utf8mb4            |
+--------------------------+--------------------+
| character_set_system     | utf8               |
+--------------------------+--------------------+
| collation_connection     | utf8mb4            |
+--------------------------+--------------------+
| collation_database       | utf8mb4            |
+--------------------------+--------------------+
| collation_server         | utf8mb4            |
+--------------------------+--------------------+

Read more here: Imported emoji in mysql table and json_encode

Leave a Reply

Your email address will not be published. Required fields are marked *