UnicodeDecodingConformance 枚举


控制 HtmlDecode 方法如何解释 Unicode 字符。Controls how Unicode characters are interpreted by the HtmlDecode methods.

public enum class UnicodeDecodingConformance
public enum UnicodeDecodingConformance
type UnicodeDecodingConformance = 
Public Enum UnicodeDecodingConformance


Auto 0

使用自动行为。Use automatic behavior. 解码行为由当前应用程序的目标框架确定。The decoding 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 decoding is strict.

Compat 2

使用兼容行为。Use compatible behavior. 指定在解码前不检查传入数据的有效性。Specifies that incoming data is not checked for validity before being decoded. 例如,输入字符串“�”会解码为 U+D84C,后者是一个不成对的代理。For example, an input string of "�" would decode as U+D84C, which is an unpaired surrogate. 此外,除非码位表示为 HTML 编码的代理,否则解码器无法知道 SMP 中的码位,因此输入字符串“𣎴”可能会生成输出字符串“𣎴”。Additionally, the decoder does not understand code points in the SMP unless they're represented as HTML-encoded surrogates, so the inputstring "𣎴" would result in the output string "𣎴".

Loose 3

使用松散行为。Use loose behavior. Compat 类似,没有有效性检查,但解码器也知道码位。Similar to Compat in that there are no validity checks, but the decoder also understands code points. 输入字符串“𣎴”正确解码为字符 U+233B4。The input string "𣎴" would decode into the character U+233B4 correctly. 此开关在解码器不知道提供程序用于生成编码字符串的格式时提供最大互操作性。This switch is meant to provide maximum interoperability when the decoder doesn't know which format the provider is using to generate the encoded string.

Strict 1

使用严格行为。Use strict behavior. 指定在解码前不检查传入的编码数据的有效性。Specifies that the incoming encoded data is checked for validity before being decoded. 例如,输入字符串“𣎴”解码为 U+233B4,但输入字符串“��”无法正确解码。For example, an input string of "𣎴" would decode as U+233B4, but an input string of "��" would fail to decode properly. 不会检查字符串中已解码数据的有效性。Already-decoded data in the string is not checked for validity. 例如,如果在解码期间跳过已解码的代理,即使该代理是不成对的代理,输入字符串“\ud800”都会生成输出字符串“\ud800”。For example, an input string of "\ud800" will result in an output string of "\ud800", as the already-decoded surrogate is skipped during decoding, even though it is unpaired.


有关如何在 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.