Php to generate xml file format ask the ox php can generate xml file format to die for unixutf-8 format? why every time I generate is pcANSI format on the code: please help me to see how to change the file format can be generated is the unixutf-8 format, thank you help: PH php generated xml file format problem
Could you tell me that php can fix the generated xml file format to unix UTF-8?
Why is every time I generate a pc in ANSI format?
Code: please help me to see how to change it so that the generated file format is in the unix UTF-8 format. thank you for your help:
PHP code
Balababara
EOF; // if (file_put_contents ("F:/over. xml ", $ str) {// echo" yesyesyes "; //} else {// echo" nononon "; //} $ dh = fopen (" f: /over. xml "," w "); $ dh2 = fwrite ($ dh, $ str); fclose ($ dh);?>
The generated file is opened in the pc ANSI format using editplus. the format to be generated is unix UTF-8.
------ Solution --------------------
Then your php program file will be saved in unix UTF-8 format.
------ Solution --------------------
Your program file is UTF-8
$ Dh2 = fwrite ($ dh, "\ xef \ xbb \ xbf". $ str );
If it is gbk, transcoding is required
$ Str = iconv ('gbk', 'utf-8', $ str );
To fully comply with the unix format, remove the 'carriage return '.
$ Str = preg_replach ("/[\ r \ n] +/s", "\ n", $ str );