IncreMan IncreMan - 5 months ago 42
JSON Question

Inserting JSON string into MySQL column UTF-8

I am generating JSON valid string like:

[{"head":"Model Name","body":"T102HA-GR015T"}]

The string generated on UTF-8 page with
header('Content-Type: text/html; charset=utf-8');
and file encoding UTF-8.

The connection to database made by PDO with

DB table & column collations are

When it inserted to db it look like:

For Russian:
[{"head":"\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438","body":"T102HA-GR015T"}]

For Hebrew:

And I want it to be inserted to db in actual lang characters, like:

For Russian:
[{"head":"Название модели","body":"T102HA-GR015T"}]

For Hebrew:

phpMyAdmin screenshot:
enter image description here

Answer Source

Thanks to @RickJames for helping, solved using JSON_UNESCAPED_UNICODE


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download