doujishan2247 2012-05-01 18:51
浏览 63

使用PHP编码UTF-16的XML(我不断获得UTF-8)

I have a PHP script that extracts an XML file from a MYSQL. I have the following line:

$xml='<?xml version="1.0" encoding="UTF-16"?>;

But the extracted file is being recognized as UTF-8 UNIX (LF): enter image description here

I need to have the encoding as UTF-16 and Windows CLRF. What is the correct syntax?

Any help is appreciated.

  • 写回答

1条回答 默认 最新

  • dpd7195 2012-05-01 20:03
    关注

    add a HTTP header:

    header('Content-type: text/xml; charset=utf-16')
    

    I'm not sure if text/xml is the best for you, you should decide it: http://www.petefreitag.com/item/381.cfm

    Also, your editor in the screenshot is set to UTF-8

    评论

报告相同问题?