Questions about the xml file format generated by php

Source: Internet
Author: User
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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.