System.Text.DecoderExceptionFallback Class

Throws System.Text.DecoderFallbackException if an encoded input byte sequence cannot be converted to a decoded output character. This class cannot be inherited.

See Also: DecoderExceptionFallback Members


public sealed class DecoderExceptionFallback : DecoderFallback


An encoding maps a Unicode character to an encoded sequence of bytes, which can subsequently be transferred to a physical medium, such as a disk, or over a communications link. Characters can be mapped in various ways, and a particular encoding is represented by a type derived from the System.Text.Encoding class. Specifically, the encoding type's GetBytes method encodes a character to a byte sequence, and the GetChars method decodes a byte sequence to a character.

A decoding operation can fail if the input byte sequence cannot be mapped by the encoding. For example, an System.Text.ASCIIEncoding object cannot decode a byte sequence that yields a character having a code point value that is outside the range U+0000 to U+007F.

In cases where an encoding or decoding conversion cannot be performed, the .NET Framework provides a failure-handling mechanism called a fallback. Your application can use the predefined .NET Framework decoder fallback, or it can create a custom decoder fallback derived from the System.Text.DecoderFallback and System.Text.DecoderFallbackBuffer classes.

The .NET Framework provides two predefined classes that implement different fallback strategies for handling decoding conversion failures. The System.Text.DecoderReplacementFallback class substitutes a string provided in place of any input byte sequence that cannot be converted. After the substitute string is emitted, the decoding operation continues converting the remainder of the input. In contrast, the System.Text.DecoderExceptionFallback class throws a System.Text.DecoderFallbackException when an invalid byte sequence is encountered.


Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions:,
Since: .NET 2.0