[100 points for help] the xml_parse_into_struct function parses XML. The Chinese garbled test code is as follows: $ xmldata & nbsp ;=& nbsp; '& lt ;? Xml & nbsp; version = "1.0" & nbsp; encoding = "UTF-[100 points for help] xml_parse_into_struct function parse XML, Chinese garbled characters
The test code is as follows:
$ Xmldata ='
Chinese
';
$ Parser = xml_parser_create ('utf-8 ');
$ Vals = array ();
Xml_parse_into_struct ($ parser, $ xmldata, $ vals );
Xml_parser_free ($ parser );
Print_r ($ vals );
PHP version 5.4.20
In the conversion result, the Chinese part is garbled.
Have you ever encountered this problem and how to solve it ...... Thank you!
------ Solution --------------------
Apparently, your program file is gbk's
$ Xmldata =' Chinese ';
$ Xmldata = iconv ('gbk', 'utf-8', $ xmldata );
------ Solution --------------------
In fact, you can also use iconv transcoding.
However, my display is normal. no garbled characters. it is estimated that the browser code is incorrect.