doudeng5218 2014-04-17 09:41
浏览 130

以unicode格式解码json

i am useing an API getting some json objects.

The one i need is: results_html

When you look at the name you see it will be html. My problem is, in the json it is unicode encoded. When i try to decode it some characters are wrong!

I tried out JSON_UNESCAPED_UNICODE and i tried out some str_replace() things like this:

$json_object = str_replace('\u2122', 'e2 84 a2;', str_replace('\u2605', 'e2 98 85', file_get_contents($url)));
        $json_decoded = json_decode($json_object);

But i didnt get any good result! Sometimes the total json crashes or the chars are bad anyway.

EDIT: Here is an example: WHen i use:

$json_object = file_get_contents($url);
$json_decoded = json_decode($json_object);
$html = $json_decoded -> results_html;

the $html will echo this in an utf8 encoded html body: â StatTrakâ¢

Does somebody have any idea?

Thank You so far.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大