简体   繁体   English

使用PHP对UTF-16进行XML编码(我一直在获取UTF-8)

[英]XML encoding UTF-16 using PHP ( I keep getting UTF-8)

I have a PHP script that extracts an XML file from a MYSQL. 我有一个PHP脚本,可从MYSQL提取XML文件。 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): 但是提取的文件被识别为UTF-8 UNIX(LF): 在此处输入图片说明

I need to have the encoding as UTF-16 and Windows CLRF. 我需要编码为UTF-16和Windows CLRF。 What is the correct syntax? 正确的语法是什么?

Any help is appreciated. 任何帮助表示赞赏。

add a HTTP header: 添加一个HTTP标头:

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 我不确定text / xml是否最适合您,您应该自己决定: http : //www.petefreitag.com/item/381.cfm

Also, your editor in the screenshot is set to UTF-8 另外,屏幕截图中的编辑器设置为UTF-8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM