System.Text

System.Text Namespace

 

The System.Text namespace contains classes that represent ASCII and Unicode character encodings; abstract base classes for converting blocks of characters to and from blocks of bytes; and a helper class that manipulates and formats String objects without creating intermediate instances of String.

ClassDescription
System_CAPS_pubclassASCIIEncoding

Represents an ASCII character encoding of Unicode characters.

System_CAPS_pubclassDecoder

Converts a sequence of encoded bytes into a set of characters.

System_CAPS_pubclassDecoderExceptionFallback

Provides a failure-handling mechanism, called a fallback, for an encoded input byte sequence that cannot be converted to an input character. The fallback throws an exception instead of decoding the input byte sequence. This class cannot be inherited.

System_CAPS_pubclassDecoderExceptionFallbackBuffer

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

System_CAPS_pubclassDecoderFallback

Provides a failure-handling mechanism, called a fallback, for an encoded input byte sequence that cannot be converted to an output character.

System_CAPS_pubclassDecoderFallbackBuffer

Provides a buffer that allows a fallback handler to return an alternate string to a decoder when it cannot decode an input byte sequence.

System_CAPS_pubclassDecoderFallbackException

The exception that is thrown when a decoder fallback operation fails. This class cannot be inherited.

System_CAPS_pubclassDecoderReplacementFallback

Provides a failure-handling mechanism, called a fallback, for an encoded input byte sequence that cannot be converted to an output character. The fallback emits a user-specified replacement string instead of a decoded input byte sequence. This class cannot be inherited.

System_CAPS_pubclassDecoderReplacementFallbackBuffer

Represents a substitute output string that is emitted when the original input byte sequence cannot be decoded. This class cannot be inherited.

System_CAPS_pubclassEncoder

Converts a set of characters into a sequence of bytes.

System_CAPS_pubclassEncoderExceptionFallback

Provides a failure-handling mechanism, called a fallback, for an input character that cannot be converted to an output byte sequence. The fallback throws an exception if an input character cannot be converted to an output byte sequence. This class cannot be inherited.

System_CAPS_pubclassEncoderExceptionFallbackBuffer

Throws EncoderFallbackException when an input character cannot be converted to an encoded output byte sequence. This class cannot be inherited.

System_CAPS_pubclassEncoderFallback

Provides a failure-handling mechanism, called a fallback, for an input character that cannot be converted to an encoded output byte sequence.

System_CAPS_pubclassEncoderFallbackBuffer

Provides a buffer that allows a fallback handler to return an alternate string to an encoder when it cannot encode an input character.

System_CAPS_pubclassEncoderFallbackException

The exception that is thrown when an encoder fallback operation fails. This class cannot be inherited.

System_CAPS_pubclassEncoderReplacementFallback

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. This class cannot be inherited.

System_CAPS_pubclassEncoderReplacementFallbackBuffer

Represents a substitute input string that is used when the original input character cannot be encoded. This class cannot be inherited.

System_CAPS_pubclassEncoding

Represents a character encoding.

To browse the .NET Framework source code for this type, see the Reference Source.

System_CAPS_pubclassEncodingInfo

Provides basic information about an encoding.

System_CAPS_pubclassEncodingProvider

Provides the base class for an encoding provider, which supplies encodings that are unavailable on a particular platform.

System_CAPS_pubclassStringBuilder

Represents a mutable string of characters. This class cannot be inherited.

To browse the .NET Framework source code for this type, see the Reference Source.

System_CAPS_pubclassUnicodeEncoding

Represents a UTF-16 encoding of Unicode characters.

System_CAPS_pubclassUTF32Encoding

Represents a UTF-32 encoding of Unicode characters.

System_CAPS_pubclassUTF7Encoding

Represents a UTF-7 encoding of Unicode characters.

System_CAPS_pubclassUTF8Encoding

Represents a UTF-8 encoding of Unicode characters.

EnumerationDescription
System_CAPS_pubenumNormalizationForm

Defines the type of normalization to perform.

The encoding classes are primarily intended to convert between different encodings or code pages and a Unicode encoding. Encoding.Unicode (UTF-16) encoding is used internally by the .NET Framework, and Encoding.UTF8 encoding is often used for storing character data to ensure portability across machines and cultures.

The classes derived from Encoding enable you to choose a fallback strategy, which determines how characters that cannot be encoded into a sequence of bytes, or bytes that cannot be decoded into characters, are handled. You can choose one of the following:

  • Exception fallback. You can choose to throw exceptions on data errors either by using a throwonerror flag that is available in some class constructors or by using the EncoderExceptionFallback and DecoderExceptionFallback classes. If you are concerned about the integrity of the data stream, throwing on an exception is recommended.

  • Replacement fallback. You can use the EncoderFallback and DecoderFallback classes to silently change a character to "?" or to the Unicode replacement character (U+FFFD).

  • Best-fit fallback. This option maps a character in one encoding to a character in another encoding. Best fit fallback is often not recommended because it can cause data loss and confusion, and is slower than simple "?" character replacements. However, for ANSI code pages the best-fit behavior is the default.

The StringBuilder class is designed for operations that perform extensive manipulations on a single string. Unlike the String class, the StringBuilder class is mutable and provides better performance when concatenating or deleting strings.

For more information about System.Text, see Character Encoding in the .NET Framework and the MSDN blog Shawn Steele's Thoughts about Windows and .NET Framework Globalization APIs.

Return to top
Show:
© 2016 Microsoft