0

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);

I don't have problem inserting emoji My problem is the old convert from mssql

.

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            |
+--------------------------+--------------------+

enter image description here

user186585
  • 512
  • 1
  • 8
  • 25

1 Answers1

2

You need to change collation to 'utf8mb4_bin' And also set charset for the mysql connection as:

$database_connection = new mysqli($server, $user,$password,$database_name); 

$database_connection->set_charset("utf8mb4");

Please refer: Storing Emojis in Mysql

Community
  • 1
  • 1
informer
  • 821
  • 6
  • 18