Why can't I set the XDocument XDeclaration encoding type to iso-8859-1?

前端 未结 3 1286
太阳男子
太阳男子 2021-01-12 14:25

Why doesn\'t the following code set the XML declaration encoding type? It always sets the encoding to utf-16 instead. Am I missing something very obvious?

v         


        
3条回答
  •  清歌不尽
    2021-01-12 14:59

    See the answer about specifying the TextWriter's encoding.

    As an aside: ISO-8859-1 is a character-set, not an encoding. Unicode is also a character-set, but UTF-16 is an encoding of the Unicode character set into a sequence of bytes. You cannot specify a document's encoding as ISO-8859-1, just as you cannot specify a document's character-set as UTF-16. Note that Unicode is the native character-set and UTF-16 is the native Unicode encoding for both .NET and Java String classes and text-based or string-based operations.

提交回复
热议问题