XmlWriter将奇怪的字符放在文档开始处 [英] XmlWriter putting strange chars at start of doc

查看:104
本文介绍了XmlWriter将奇怪的字符放在文档开始处的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用XmlWriter,但是每次创建文档时,它会将这三个奇怪的字符放在文档的开头:

I''m using an XmlWriter but everytime I create a document it is putting these three strange characters at the beginning of my document:

</b><?xml version="1.0" encoding="utf-8"?>



有没有其他人看到过此消息和/或知道如何解决它?!?!?!



Has anyone else seen this and/or know how to fix it?!?!?!

推荐答案

John242424写道:
</b><?xml version ="1.0" encoding ="utf-8"?>

这些是UTF-8前缀字符0xEF,0xBB,0xBF,告诉任何读取文件的人如何对其进行解码.请注意,UTF-8不是Unicode.
John242424 wrote:
</b><?xml version="1.0" encoding="utf-8"?>

These are the UTF-8 prefix characters 0xEF,0xBB,0xBF which tells anyone reading the file how to decode it. Note that UTF-8 is NOT Unicode.


John242424写道:
John242424 wrote:

当我将编码更改为Unicode时,这些字符不见了.

When I changed encoding to Unicode, these chars are gone.



请注意,Unicode还使用前缀字符(0xFF 0xFE)来标识编码.无论哪种情况(UTF-8或Unicode),如果您使用正确的C#/.NET类进行读/写,您都不必担心,因为该框架将为您正确地管理它.如果您要编写自己的读取器/写入器,请确保正确管理编码密钥.



Be aware that Unicode also uses prefix characters (0xFF 0xFE) to identify the encoding. In either case (UTF-8 or Unicode) if you are reading/writing with the correct C#/.NET classes you don''t need to worry about this as the framework will manage it correctly for you. If you are writing your own reader/writer then make sure you manage the encoding keys correctly.


它们是用于标识文件以 Unicode存储的事实的标记,和字节顺序 UTF-8. ((因此,它们应该在那里))
They are the markers used to identify the fact that the file is stored in Unicode, and the byte order UTF-8. (( So, they should be there ))


这篇关于XmlWriter将奇怪的字符放在文档开始处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆