Home > Backend Development > PHP Tutorial > php把这种形式的数据转换成汉字会丢失部分字符和数字,求转码的解决方法

php把这种形式的数据转换成汉字会丢失部分字符和数字,求转码的解决方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:33:43
Original
990 people have browsed it

php把这种形式的数据转换成汉字会丢失部分字符和数字,求转码的解决办法。
$code = xml_to_json($code);
用这个函数转换后,汉字等字符会变成下面这样子的
u6c5b\u671f\u5c3e\u58f0\u7684\u5230\u6765\uff0c\u6211\u7701\u5f00\u59cb\u8fdb\u5165\u6c34\u5229\u5efa\u8bbe\u7684\u9ec4\u91d1\u65f6\u671f\u3002\u8bb0\u80058\u670826\u65e5\u83b7\u6089\uff0c\u4eca\u5e74\uff0c\u6211\u7701\u5c06\u5b8c\u6210\u6c34\u5229\u6295\u8d44\u8fbe154\u4ebf\u5143\uff0c\u91cd\u70b9\u6db5\u76d616\u4e2a\u65b9\u9762\u51713286\u4e2a\u9879\u76ee\u3002\n\n


我现在下面这个函数把上面这样子的变成汉字,但是会丢失部分字符和数字,求解决办法,。

<br />$code = preg_replace("#\\\u([0-9a-f]+)#ie", "iconv('UCS-2', 'UTF-8', pack('H4', '\\1'))", $code);<br />print $code;<br />
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template