XmlTextWriter.WriteSurrogateCharEntity(Char, Char) 方法

定义

为代理项字符对生成并写入代理项字符实体。Generates and writes the surrogate character entity for the surrogate character pair.

public:
 override void WriteSurrogateCharEntity(char lowChar, char highChar);
public override void WriteSurrogateCharEntity (char lowChar, char highChar);
override this.WriteSurrogateCharEntity : char * char -> unit
Public Overrides Sub WriteSurrogateCharEntity (lowChar As Char, highChar As Char)

参数

lowChar
Char

低代理项。The low surrogate. 它必须是介于 0xDC000xDFFF 之间的值。This must be a value between 0xDC00 and 0xDFFF.

highChar
Char

高代理项。The high surrogate. 它必须是介于 0xD8000xDBFF 之间的值。This must be a value between 0xD800 and 0xDBFF.

例外

传递了无效的代理项字符对。An invalid surrogate character pair was passed.

注解

备注

从 .NET Framework 2.0 开始,我们建议 XmlWriter 使用 XmlWriter.Create 方法和类创建实例, XmlWriterSettings 以利用新功能。Starting with the .NET Framework 2.0, we recommend that you create XmlWriter instances by using the XmlWriter.Create method and the XmlWriterSettings class to take advantage of new functionality.

此方法仅适用于使用 UTF-16 编码的系统。This method is only applicable on systems that use UTF-16 encoding.

代理项字符实体是以十六进制格式编写的。The surrogate character entity is written in hexadecimal format. 代理项字符的范围为 #x10000 #x10FFFFThe range for surrogate characters is #x10000 to #x10FFFF. 以下公式用于生成代理项字符实体: (highChar - 0xD800) * 0x400 + (lowChar - 0xDC00) + 0x10000The following formula is used to generate the surrogate character entity: (highChar - 0xD800) * 0x400 + (lowChar - 0xDC00) + 0x10000.

对于 HTML 和 XML,文档字符集 (,因此) 的数字字符引用的表示法基于 UCS [ISO-10646]。For both HTML and XML, the document character set (and therefore the notation of numeric character references) is based on UCS [ISO-10646]. 因此,在某些情况下,源文档中的单个数字字符引用可以与字符串中的 2 16 位单元相对应 (高代理项和低代理项) 。A single numeric character reference in a source document may therefore in some cases correspond to two 16-bit units in a string (a high surrogate and a low surrogate). 这些16位单元称为代理项对。These 16-bit units are referred to as a surrogate pair.

有关代理项或字符的详细信息,请参阅 Unicode 3.0/unicode 2.0 标准的3.7 节或 W3C XML 1.0 建议的第2.2 部分For more information regarding surrogates or characters, refer to section 3.7 of the Unicode 3.0/Unicode 2.0 standard, or section 2.2 of the W3C XML 1.0 Recommendation.

适用于