-1

i can't print the characters in encode. even i tried the ways ;

echo json_encode($user,JSON_UNESCAPED_UNICODE);

or iconv("ISO-8859-1", "UTF-8",$user)

Can you help me ? here codes;

$user = "ğığığı";
echo json_encode($user);

thanks for help.

  • 1
    Even if you pass the `JSON_UNESCAPED_UNICODE` parameter, you should also make sure that everything (and absolutely everything) is UTF-8 encoded. I have previously written [**an answer**](http://stackoverflow.com/questions/31897407/mysql-and-php-utf-8-with-cyrillic-characters/31899827#31899827) that contains a little checklist, that will cover *most* of the charset issues in a PHP/MySQL application. There's also a more in-depth topic, [UTF-8 All the Way Through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through). Also, what if you print `$user` directly - is it correct? – Qirel Jul 11 '17 at 20:23

1 Answers1

0

You should use

echo json_encode($user,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);

You can see it work here http://sandbox.onlinephpfunctions.com/code/05d859c4b23417e54aad12fd96c8548949075c67

JTC
  • 3,344
  • 3
  • 28
  • 46