zoukankan      html  css  js  c++  java
  • php如何将json中的unicode编码转为汉字

    linux
    $str=preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $str);

    windows
    $str=preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2LE', 'UTF-8', pack('H4', '……

     

     

    header("Content-type: text/html; charset=utf-8");
    
    $str = '$d=[{"_id":{"$id":"4fda7d42741d727c14000000"},"name":"\u519c\u592b\u5c71\u6cc9","bc":"123456","pic":"d: pic\water.jpg","aid":"232fd4df3"}]
    $c=[{"_id":{"$id":"4fdaa7f3741d725816000000"},"bc":"012345678","name":"\u7ef4\u8fbe\u7eb8\u5dfe","cls":{"id":"125","name":"\u65e5\u7528\u54c1"},"std":{"name":"\u5f20\u6570","val":"10"}}]';
    
    $str=preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $str);
    echo $str;
  • 相关阅读:
    DES加密/解密
    HMACSha1加密方法
    .Net 计算文件大小函数
    maven项目打包
    08.29
    keep健身计划
    正则验证表单内容
    高德地图API
    Invalid location of tag (div)。
    08.15
  • 原文地址:https://www.cnblogs.com/guke/p/2584116.html
Copyright © 2011-2022 走看看