Encoding.EncoderFallback Property

Definition

Gets or sets the EncoderFallback object for the current Encoding object.

public System.Text.EncoderFallback EncoderFallback { get; }
public System.Text.EncoderFallback EncoderFallback { get; set; }
[System.Runtime.InteropServices.ComVisible(false)]
public System.Text.EncoderFallback EncoderFallback { get; set; }

Property Value

The encoder fallback object for the current Encoding object.

Attributes

Exceptions

The value in a set operation is null.

A value cannot be assigned in a set operation because the current Encoding object is read-only.

Remarks

The EncoderFallback object represents an error handler that is invoked when a character cannot be converted into an encoded byte sequence. Any one of the following handler types is supported:

  • A best-fit fallback handler, which replaces characters that cannot be encoded with some suitable replacement character.

  • A replacement fallback handler, which replaces characters that cannot be encoded with some arbitrary replacement character. .NET includes one replacement fallback handler, EncoderFallback, which by default replaces characters that cannot be encoded with a question mark ("?") character.

  • An exception fallback handler, which throws an exception when characters cannot be encoded. .NET includes one exception fallback handler, EncoderExceptionFallback, which throws an EncoderFallbackException when characters cannot be decoded.

Applies to

Product Versions
.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
.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

See also