M
M
Michael R.2017-02-23 13:54:08
PHP
Michael R., 2017-02-23 13:54:08

How to translate json text u0418u0432u * into Russian letters?

Hello!
I take data from the database, output it, everything would be fine, but any Russian word is displayed as u0418. I dug through a bunch of forums, but did not get a positive result.
Tried using the following decoding option:

$customerArray = json_decode($query['customer'], true);
print_r($customerArray['customer_name']); // u0418u0432u0430u043du044bu0447

Of course, the option didn't work. HELP!
Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vlad Malinichev, 2017-02-23
@malinichev

php.net/manual/ru/json.constants.php
JSON_UNESCAPED_UNICODE

I
Ivan, 2017-02-23
@LiguidCool

This is UTF 8 encoding, look in the connection settings to the database in what format the file is on the server, well, and so on.

S
Stalker_RED, 2017-02-23
@Stalker_RED

As Vlad Malinichev said , you need the JSON_UNESCAPED_UNICODE flag.
Besides it, there are a few more useful ones:

json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question