EncoderReplacementFallback 构造函数

定义

初始化 EncoderReplacementFallback 类的新实例。Initializes a new instance of the EncoderReplacementFallback class.

重载

EncoderReplacementFallback()

初始化 EncoderReplacementFallback 类的新实例。Initializes a new instance of the EncoderReplacementFallback class.

EncoderReplacementFallback(String)

使用指定的替换字符串初始化 EncoderReplacementFallback 类的新实例。Initializes a new instance of the EncoderReplacementFallback class using a specified replacement string.

EncoderReplacementFallback()

初始化 EncoderReplacementFallback 类的新实例。Initializes a new instance of the EncoderReplacementFallback class.

public:
 EncoderReplacementFallback();
public EncoderReplacementFallback ();
Public Sub New ()

注解

默认情况下,作为此对象的值的替换字符串 EncoderReplacementFallback 为 "?"。By default, the replacement string that is the value of this EncoderReplacementFallback object is "?".

另请参阅

适用于

EncoderReplacementFallback(String)

使用指定的替换字符串初始化 EncoderReplacementFallback 类的新实例。Initializes a new instance of the EncoderReplacementFallback class using a specified replacement string.

public:
 EncoderReplacementFallback(System::String ^ replacement);
public EncoderReplacementFallback (string replacement);
new System.Text.EncoderReplacementFallback : string -> System.Text.EncoderReplacementFallback
Public Sub New (replacement As String)

参数

replacement
String

编码操作中转换的、用以替代无法编码的输入字符的字符串。A string that is converted in an encoding operation in place of an input character that cannot be encoded.

例外

replacementnullreplacement is null.

replacement 包含无效的代理项对。replacement contains an invalid surrogate pair. 也就是说,代理项不是由一个高代理项组件后面跟着一个低代理项组件组成。In other words, the surrogate does not consist of one high surrogate component followed by one low surrogate component.

注解

replacement参数初始化作为此对象的值的替换字符串 EncoderReplacementFallbackThe replacement parameter initializes the replacement string that is the value of this EncoderReplacementFallback object. 应用程序必须提供 replacement 只包含可在目标编码中进行编码的字符的值。You application must provide a replacement value that contains only characters that can be encoded in the target encoding. 否则,会引发一个递归回退结果 ArgumentExceptionOtherwise, a recursive fallback results, causing an ArgumentException. 例如,为对象提供的回退 ASCIIEncoding 不能包含字符 "的" (U + 00BF) ,因为该字符本身不是有效的 ASCII 字符。For example, the fallback provided for an ASCIIEncoding object cannot include the character "¿" (U+00BF) because that character is itself not a valid ASCII character.

因此,U + FFFD 是的回退字符串的一个不错选择, DecoderExceptionFallback 并不是此类的一个不错选择。As a result of this, U+FFFD, which is a good choice for a fallback string for DecoderExceptionFallback, is not generally a good choice for this class. 此外,不能在回退字符串中使用空字符 (U + 0000) 。Also, the null character (U+0000) cannot be used in the fallback string.

另请参阅

适用于