Fallback Encoding Application Sample
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
This sample demonstrates features of the Encoding class, including a fallback mechanism, new to the .NET Framework version 2.0, that allows you to specify its behavior when it encounters problems during the encoding or decoding process.
For information about using the samples, see the following topics:
To build the sample using the Command Prompt
Open the Command Prompt window and navigate to one of the language-specific subdirectories under the EncodingApp directory. For information about required settings and the SDK Command Prompt, see How to: Set Sample Settings.
Type msbuild EncodingAppCS.sln or msbuild EncodingAppVB.sln, depending on your choice of programming language.
To build the sample using Visual Studio
Open Windows Explorer and navigate to one of the language-specific subdirectories under the EncodingApp directory.
Double-click the EncodingAppCS.sln or EncodingAppVB.sln file, depending on your choice of programming language, to open the file in Visual Studio.
From the Build menu, select Build Solution.
The application will be built in the default \bin or \bin\Debug subdirectory.
To run the sample
In Windows Explorer or in the Command Prompt window, navigate to the directory that contains the new executable.
Double-click the icon for the EncodingApplication file in Windows Explorer, or type EncodingApplication.exe in the Command Prompt window to open the application.
Remarks
The sample builds a Windows Forms application. You can launch and run it like any Windows application.
This sample highlights the EncoderFallback and DecoderFallback classes and their derived types, which expose static methods and fields that allow developers to specify the fallback behavior of an Encoding in cases where it cannot encode or decode a character or byte.
The EncodingApplication executable file displays the encoding and decoding of characters and bytes in any encoding format supported by the .NET Framework. You can view decimal or hexadecimal representations of any character in the Unicode standard. For more information about the Unicode Standard, see the specification at www.unicode.org.
The DecoderExceptionFallback and DecoderReplacementFallback types are derived from the DecoderFallback class, and the EncoderExceptionFallback and EncoderReplacementFallback types are derived from the EncoderFallback class. Each of these types is associated with a corresponding class derived from DecoderFallbackBuffer or EncoderFallbackBuffer. The encoding fallback mechanism depends on the functionality exposed by these closely related classes.
See Also
Reference
DecoderExceptionFallback class
DecoderReplacementFallback class
EncoderExceptionFallback class
EncoderReplacementFallback class