Json_encode Charset problem Json_encode Charset problem json json

Json_encode Charset problem


try it:

<?echo json_encode(array('şüğçö'), JSON_UNESCAPED_UNICODE);


In JSON any character in strings may be represented by a Unicode escape sequence. Thus "\u015f\u00fc\u011f\u00e7\u00f6" is semantically equal to "şüğçö".

Although those character can also be used plain, json_encode probably prefers the Unicode escape sequences to avoid character encoding issues.


PHP 5.4 adds the option JSON_UNESCAPED_UNICODE, which does what you want. Note that json_encode always outputs UTF-8.