Läs på engelska Redigera

Dela 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.

C#
public abstract bool Fallback(char charUnknown, int index);

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

.NET 10 och andra versioner
Produkt Versioner
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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.

C#
public abstract bool Fallback(char charUnknownHigh, char charUnknownLow, int index);

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

.NET 10 och andra versioner
Produkt Versioner
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0