Answer the question
In order to leave comments, you need to log in
How to decode the letter "yo"?
There is a json file with text where there is a letter "ё" :
[{
"id": 25,
"pid": "0CjqYfx3NU1AghsPVoGFullXwl4umV",
"message": "Just yo is crazy!"
}]
Function to decode json to utf-8 :
function normJsonStr($str) {
$pattern = "/\\\\u([a-f0-9]{4})/i";
$callback = function ($m) {
return chr(hexdec($m[1])-1072+224);
};
$str = preg_replace_callback($pattern, $callback, $str);
return iconv('CP1251', 'UTF-8', $str);
}
echo normJsonStr(json_encode($json));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question