Bewerken

Share via


EncoderFallbackBuffer.Fallback Method

Definition

Indicates whether a substitute string is available when the original input cannot be encoded, or whether the original input should be ignored.

Overloads

Fallback(Char, Int32)

When overridden in a derived class, prepares the fallback buffer to handle the specified input character.

Fallback(Char, Char, Int32)

When overridden in a derived class, prepares the fallback buffer to handle the specified surrogate pair.

Fallback(Char, Int32)

Source:
EncoderFallback.cs
Source:
EncoderFallback.cs
Source:
EncoderFallback.cs

When overridden in a derived class, prepares the fallback buffer to handle the specified input character.

public:
 abstract bool Fallback(char charUnknown, int index);
public abstract bool Fallback (char charUnknown, int index);
abstract member Fallback : char * int -> bool
Public MustOverride Function Fallback (charUnknown As Char, index As Integer) As Boolean

Parameters

charUnknown
Char

An input character.

index
Int32

The index position of the character in the input buffer.

Returns

true if the fallback buffer can process charUnknown; false if the fallback buffer ignores charUnknown.

Remarks

The Encoding.GetBytes and Encoder.Convert methods call Fallback(Byte[], Int32) if they encounter an unknown input character that cannot be encoded. A return value of true indicates that the fallback buffer can process the input character, which causes the calling method to call the GetNextChar method to obtain each character of the fallback buffer. Because it does not process individual characters, the Fallback method in an exception fallback handler throws an exception.

Applies to

Fallback(Char, Char, Int32)

Source:
EncoderFallback.cs
Source:
EncoderFallback.cs
Source:
EncoderFallback.cs

When overridden in a derived class, prepares the fallback buffer to handle the specified surrogate pair.

public:
 abstract bool Fallback(char charUnknownHigh, char charUnknownLow, int index);
public abstract bool Fallback (char charUnknownHigh, char charUnknownLow, int index);
abstract member Fallback : char * char * int -> bool
Public MustOverride Function Fallback (charUnknownHigh As Char, charUnknownLow As Char, index As Integer) As Boolean

Parameters

charUnknownHigh
Char

The high surrogate of the input pair.

charUnknownLow
Char

The low surrogate of the input pair.

index
Int32

The index position of the surrogate pair in the input buffer.

Returns

true if the fallback buffer can process charUnknownHigh and charUnknownLow; false if the fallback buffer ignores the surrogate pair.

Remarks

The Encoding.GetBytes and Encoder.Convert methods call Fallback(Char, Char, Int32) if they encounter a surrogate pair in their input. A return value of true indicates that the fallback buffer can process the surrogate pair, which causes the calling method to call the GetNextChar method to obtain each character of the fallback buffer. Because it does not process individual characters, the Fallback method in an exception fallback handler throws an exception.

Applies to