2

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 charset=utf8

DB table & column collations are utf8_general_ci

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: [{"head":"\u05d3\u05d2\u05dd","body":"T102HA-GR015T"}]

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

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

For Hebrew: [{"head":"דגם","body":"T102HA-GR015T"}]

phpMyAdmin screenshot: enter image description here

2
  • 2
    Something (other than MySQL) is encoding it... See stackoverflow.com/documentation/php/617/json/2019/… Commented Dec 30, 2016 at 16:19
  • @RickJames thanks a lot, it helped me to resolve it with $array = json_encode($array, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); Commented Jan 1, 2017 at 11:18

1 Answer 1

2

Thanks to @RickJames for helping, solved using JSON_UNESCAPED_UNICODE

$array = json_encode($array, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.