How does php convert unicode encoding in json into Chinese characters? There are two json data
$ 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"}]
How to convert unicode characters into Chinese characters
$ D = [{"_ id": {"$ id": "4fda7d42741d727c14000000"}, "name": "Nongfu Spring", "bc": "123456 ", "pic": "d: pic \ water.jpg", "aid": "232fd4df3"}]
$ C = [{"_ id": {"$ id": "4fdaa7f3741d725816000000"}, "bc": "012345678", "name": "Vida paper towel ", "cls": {"id": "125", "name": "Daily Necessities"}, "std": {"name": "Zhangshu", "val ": "10"}]
Which of the following can help you solve the problem? thank you ~~
Reply to discussion (solution)
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 ','......
Reference the reply on the third floor:
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 '......
No, is it written like this?
$ C = preg_replace ("# \\\ u ([0-9a-f] {4}) # ie", "iconv ('ucs-2le', 'utf-8 ', pack ('h4 ',' \ 1 ') ", $ c );
Echo $ c;
$ C output is
[{"_ Id": {"$ id": "4fdaa7f3741d725816000000"}, "bc": "012345678", "name ":"? Tired? Too many? "," Cls ": {" id ":" 125 "," name ":"? Activities> 〉?? "}," Std ": {" name ":"??? "," Val ":" 10 "}]
I am a windows platform. how can I solve this problem?
How can this problem be solved?
I tried,
$ 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;
If the code is garbled, remember to change the browser encoding.
Remember to use UTF-8 after encoding
I know what you mean ~ No problem as long as UTF-8 is transmitted
How can this problem be solved?
I tried,
$ Str = '$ d = [{"_ id": {"$ id": "4fda7d42741d727c14000000"}, "name": "\ u519c \ u592b \ u5c71 \ u6cc9 ", "bc": "123456", "pic": "d: pic \ water.jpg", "aid": "232fd4df3"}]
$ C = [{"_ id": {"$ id": "4fdaa7f3741d7 ......
Why can't I display it? the result is as follows:
$ D = [{"_ id": {"$ id": "4fda7d42741d727c14000000"}, "name ":"?? How does one distinguish between two variables? "," Bc ":" 123456 "," pic ":" d: pic \ water.jpg "," aid ": "232fd4df3"}] $ c = [{"_ id": {"$ id": "4fdaa7f3741d725816000000"}, "bc": "012345678", "name ": "Discuss your contribution", "cls": {"id": "125", "name ":"? WHY ??? "}," Std ": {" name ":" identifier ?? "," Val ":" 10 "}]
I can't use ie. why? Solution ~~
How can this problem be solved?
I tried,
$ Str = '$ d = [{"_ id": {"$ id": "4fda7d42741d727c14000000"}, "name": "\ u519c \ u592b \ u5c71 \ u6cc9 ", "bc": "123456", "pic": "d: pic \ water.jpg", "aid": "232fd4df3"}]
$ C = [{"_ id": {"$ id": "4fdaa7f3741d7 ......
Oh ~~ Yes, yes. Add header ("Content-type: text/html; charset = utf-8,
Thank you for your help.
Lian is easy to handle