UnicodeEncodingConformance UnicodeEncodingConformance UnicodeEncodingConformance UnicodeEncodingConformance Enum

定义

控制 HtmlEncode 方法如何输出 Unicode 字符。Controls how Unicode characters are output by the HtmlEncode methods.

public enum class UnicodeEncodingConformance
public enum UnicodeEncodingConformance
type UnicodeEncodingConformance = 
Public Enum UnicodeEncodingConformance
继承
UnicodeEncodingConformanceUnicodeEncodingConformanceUnicodeEncodingConformanceUnicodeEncodingConformance

字段

Auto Auto Auto Auto 0

使用自动行为。Use automatic behavior. Unicode 编码行为由当前应用程序的目标框架确定。The Unicode encoding behavior is determined by current application's target Framework. 对于 .NET Framework 4.5.NET Framework 4.5 以及更高版本,Unicode 编码行为是严格的。For .NET Framework 4.5.NET Framework 4.5 and later, the Unicode encoding behavior is strict.

Compat Compat Compat Compat 2

使用兼容行为。Use compatible behavior. 指定在调用 HtmlEncode 方法之一时将各个 UTF-16 代理项码位按原样输出。Specifies that individual UTF-16 surrogate code points are output as-is when one of HtmlEncode methods is called. 例如,指定字符串“\uD84C\uDFB4”(或“\U000233B4”),则 HtmlEncode 的输出为“\uD84C\uDFB4”(未编码输入)。For example, given a string "\uD84C\uDFB4" (or "\U000233B4"), the output of HtmlEncode is "\uD84C\uDFB4" (the input is not encoded).

Strict Strict Strict Strict 1

使用严格行为。Use strict behavior. 指定在调用 HtmlEncode 方法之一时将各个 UTF-16 代理项码位合并为一个码位。Specifies that individual UTF-16 surrogate code points are combined into a single code point when one of the HtmlEncode methods is called. 例如,给定输入的字符串为“\uD84C\uDFB4”(或“\U000233B4”),则 HtmlEncode 方法的输出为“𣎴”。For example, given the input string "\uD84C\uDFB4" (or "\U000233B4"), the output of the HtmlEncode methods is "𣎴".

如果输入是格式不正确的 UTF-16 字符串(例如,它包含不成对的代理),则在对错误的代码点进行 HTML 编码前,会将替换为 U+FFFD(Unicode 替换字符)。If the input is a malformed UTF-16 string (it contains unpaired surrogates, for example), the bad code points will be replaced with U+FFFD (Unicode replacement char) before being HTML-encoded.

注解

有关如何在 HTML 中对 Unicode 字符进行编码的详细信息,请参阅在标记和 CSS 中使用字符转义For more information on how Unicode characters are supposed to be encoded in HTML, see Using character escapes in markup and CSS.

适用于

另请参阅