EncoderReplacementFallback

EncoderReplacementFallback


Provides a failure handling mechanism, called a fallback, for an input character that cannot be converted to an output byte sequence. The fallback uses a user-specified replacement string instead of the original input character.


Implements:

EncoderFallback 
IObject 

Public:

Properties:

NameDescription
 DefaultString (get) Gets the replacement string that is the value of the EncoderReplacementFallback object.  
 MaxCharCount (get) Gets the number of characters in the replacement string for the EncoderReplacementFallback object.  

Methods:

NameDescription
 CreateFallbackBuffer Creates a EncoderFallbackBuffer object that is initialized with the replacement string of this EncoderReplacementFallback object.  
 Equals Determines whether the specified value passed in is equal to the current object.  
 GetHashCode Serves as the default hash function.  
 ToString Returns a string that represents the current object.  

Remarks

A common reason for an encoding or decoding operation to fail is if the underlying encoding class does not provide a mapping between a character and an equivalent byte sequence. For example , an ASCIIEncoding object cannot encode a character having a Unicode code point value that is outside the range U+0000 to U+007F. If the input character cannot be converted to an output byte sequence, a EncoderReplacementFallback object substitutes a specified replacement string for the original input character. The conversion process encodes the replacement string and then continues to process the remainder of the original input.

The replacement string used by an EncoderReplacementFallback object is determined by the call to its class constructor. Two options are available:

If you choose a fallback string to use with this class, make sure that the string is composed entirely of characters that can be encoded in the target encoding. Otherwise, a recursive fallback results, causing an ArgumentException.

See Also

Project CorLib Overview

Class EncoderReplacementFallback Overview