BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.Text.Encoding System.Runtime.InteropServices.ComVisible(true)

Encoding is the process of transforming a set of Unicode characters into a sequence of bytes. Decoding is the process of transforming a sequence of encoded bytes into a set of Unicode characters.

corresponds to the Windows code page 20127. Because ASCII is a 7-bit encoding, ASCII characters are limited to the lowest 128 Unicode characters, from U+0000 to U+007F. If you use the default encoder returned by the property or the constructor, characters outside that range are replaced with a question mark (?) before the encoding operation is performed. Because the class supports only a limited character set, the , , and classes are better suited for globalized applications. The following considerations can help you to decide whether to use :

Some protocols require ASCII or a subset of ASCII. In these cases ASCII encoding is appropriate.

If an 8-bit encoding is expected, then ASCII probably isn't the correct choice. Instead, consider using UTF8 instead of ASCII. For the characters U+0000 through U+007F, the results are identical, but all Unicode characters are representable in UTF-8, which avoids data loss.

does not provide error detection. For security reasons, you should use , , or and enable error detection.

The method determines how many bytes result in encoding a set of Unicode characters, and the method performs the actual encoding.

Likewise, the method determines how many characters result in decoding a sequence of bytes, and the and methods perform the actual decoding.

Note that the default constructor by itself might not have the appropriate behavior for your application. You might want to consider setting the or property to or to prevent sequences with the 8th bit set. Custom behavior might also be appropriate for these cases.

Represents an ASCII character encoding of Unicode characters.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The class does not provide error detection. For security reasons, you should use the , , or class and enable error detection.

  If you choose to use ASCII encoding, this constructor may not provide the appropriate fallback behavior for your application. It uses the and classes to replace every character outside the range of U+0000 through U+007F with a question mark (?). Instead, you can call the or method and pass it and objects to use exception fallback.

  supports only the Unicode character values between U+0000 and U+007F. Therefore, , , and are better suited for globalized applications.

  Initializes a new instance of the class.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` is .

  To calculate the exact array size required by to store the resulting bytes, the application uses . To calculate the maximum array size, the application should use . The method generally allows allocation of less memory, while the method generally executes faster.

  Calculates the number of bytes produced by encoding the characters in the specified .

  The number of bytes produced by encoding the specified characters.

  The containing the set of characters to encode. 0
- Method
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Runtime.InteropServices.ComVisible(false)
  System.Int32 `` ``

  To calculate the exact array size required by to store the resulting bytes, the application uses . To calculate the maximum array size, the application should use . The method generally allows allocation of less memory, while the method generally executes faster.

  Calculates the number of bytes produced by encoding a set of characters starting at the specified character pointer.

  The number of bytes produced by encoding the specified characters.

  A pointer to the first character to encode. The number of characters to encode.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` `` is .

  < 0.

  -or-

  < 0.

  -or-

  and do not specify a valid range in (i.e. ( + - 1) > .Length).

  To calculate the exact array size required by to store the resulting bytes, the application uses . To calculate the maximum array size, the application should use . The method generally allows allocation of less memory, while the method generally executes faster.

  Calculates the number of bytes produced by encoding a set of characters from the specified character array.

  The number of bytes produced by encoding the specified characters.

  The character array containing the set of characters to encode. The index of the first character to encode. The number of characters to encode. 0
- Method
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Runtime.InteropServices.ComVisible(false)
  System.Int32 `` `` `` ``

  To calculate the exact array size required by to store the resulting bytes, the application uses . To calculate the maximum array size, the application should use . The method generally allows allocation of less memory, while the method generally executes faster.

  Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, the application should use the or the provided by the method or the method, respectively.

  does not provide error detection. Any Unicode character greater than U+007F is translated to an ASCII question mark ("?").

  For security reasons, your application is recommended to use , , or and enable error detection.

  Encodes a set of characters starting at the specified character pointer into a sequence of bytes that are stored starting at the specified byte pointer.

  The actual number of bytes written at the location indicated by .

  A pointer to the first character to encode. The number of characters to encode. A pointer to the location at which to start writing the resulting sequence of bytes. The maximum number of bytes to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` `` `` ``

  (.Length - ) < .

  is .

  -or-

  is .

  < 0.

  -or-

  < 0.

  -or-

  (.Length - ) < .

  -or-

  < 0.

  -or-

  > .Length.

  To calculate the exact array size required by to store the resulting bytes, the application uses . To calculate the maximum array size, the application should use . The method generally allows allocation of less memory, while the method generally executes faster.

  Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, the application should use the or the provided by the method or the method, respectively.

  does not provide error detection. Any Unicode character greater than U+007F is encoded as the ASCII question mark ("?").

  For security reasons, your application is recommended to use , , or and enable error detection.

  Encodes a set of characters from the specified character array into the specified byte array.

  The actual number of bytes written into .

  The character array containing the set of characters to encode. The index of the first character to encode. The number of characters to encode. The byte array to contain the resulting sequence of bytes. The index at which to start writing the resulting sequence of bytes. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` `` `` ``

  (.Length - ) < .

  is .

  -or-

  is .

  < 0.

  -or-

  < 0.

  -or-

  (.Length - ) < .

  -or-

  < 0.

  -or-

  >= .Length.

  The index of the first character to encode. The number of characters to encode. The byte array to contain the resulting sequence of bytes. The index at which to start writing the resulting sequence of bytes.

  To calculate the exact array size required by to store the resulting bytes, the application uses . To calculate the maximum array size, the application should use . The method generally allows allocation of less memory, while the method generally executes faster.

  Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, the application should use the or the provided by the method or the method, respectively.

  does not provide error detection. Any Unicode character greater than U+007F is encoded as the ASCII question mark ("?").

  For security reasons, your application is recommended to use , , or and enable error detection.

  Encodes a set of characters from the specified into the specified byte array.

  The actual number of bytes written into .

  The containing the set of characters to encode. The index of the first character to encode. The number of characters to encode. The byte array to contain the resulting sequence of bytes. The index at which to start writing the resulting sequence of bytes. 0
- Method
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Runtime.InteropServices.ComVisible(false)
  System.Int32 `` ``

  To calculate the exact array size required by to store the resulting characters, the application uses . To calculate the maximum array size, the application should use . The method generally allows allocation of less memory, while the method generally executes faster.

  Calculates the number of characters produced by decoding a sequence of bytes starting at the specified byte pointer.

  The number of characters produced by decoding the specified sequence of bytes.

  A pointer to the first byte to decode. The number of bytes to decode.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` `` is .

  < 0.

  -or-

  < 0.

  -or-

  (.Length - ) < .

  To calculate the exact array size required by to store the resulting characters, the application uses . To calculate the maximum array size, the application should use . The method generally allows allocation of less memory, while the method generally executes faster.

  Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.

  The number of characters produced by decoding the specified sequence of bytes.

  The byte array containing the sequence of bytes to decode. The index of the first byte to decode. The number of bytes to decode. 0
- Method
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Runtime.InteropServices.ComVisible(false)
  System.Int32 `` `` `` ``

  To calculate the exact array size required by to store the resulting characters, the application uses . To calculate the maximum array size, the application should use . The method generally allows allocation of less memory, while the method generally executes faster.

  Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, the application should use the or the provided by the method or the method, respectively.

  does not provide error detection. Any byte greater than hexadecimal 0x7F is decoded as the Unicode question mark ("?").

  For security reasons, your application is recommended to use , , or and enable error detection.

  Decodes a sequence of bytes starting at the specified byte pointer into a set of characters that are stored starting at the specified character pointer.

  The actual number of characters written at the location indicated by .

  A pointer to the first byte to decode. The number of bytes to decode. A pointer to the location at which to start writing the resulting set of characters. The maximum number of characters to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` `` `` ``

  (.Length - ) < .

  is .

  -or-

  is .

  < 0.

  -or-

  < 0.

  -or-

  (.Length - ) < .

  -or-

  < 0.

  -or-

  > .Length.

  To calculate the exact array size required by to store the resulting characters, the application uses . To calculate the maximum array size, the application should use . The method generally allows allocation of less memory, while the method generally executes faster.

  Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, the application should use the or the provided by the method or the method, respectively.

  does not provide error detection. Any byte greater than hexadecimal 0x7F is decoded as the Unicode question mark ("?").

  For security reasons, your application is recommended to use , , or and enable error detection.

  Decodes a sequence of bytes from the specified byte array into the specified character array.

  The actual number of characters written into .

  The byte array containing the sequence of bytes to decode. The index of the first byte to decode. The number of bytes to decode. The character array to contain the resulting set of characters. The index at which to start writing the resulting set of characters. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Text.Decoder

  The method converts sequential blocks of bytes into sequential blocks of characters, in a manner similar to the method of this class. However, a maintains state information between calls so it can correctly decode byte sequences that span blocks. The also preserves trailing bytes at the end of data blocks and uses the trailing bytes in the next decoding operation. Therefore, and are useful for network transmission and file operations, because those operations often deal with blocks of data instead of a complete data stream.

  Obtains a decoder that converts an ASCII encoded sequence of bytes into a sequence of Unicode characters.

  A that converts an ASCII encoded sequence of bytes into a sequence of Unicode characters.

- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Text.Encoder

  The method converts sequential blocks of characters into sequential blocks of bytes, in a manner similar to the method of this class. However, an maintains state information between calls so it can correctly encode character sequences that span blocks. The also preserves trailing characters at the end of data blocks and uses the trailing characters in the next encoding operation. For example, a data block might end with an unmatched high surrogate, and the matching low surrogate might be in the next data block. Therefore, and are useful for network transmission and file operations, because those operations often deal with blocks of data instead of a complete data stream.

  Obtains an encoder that converts a sequence of Unicode characters into an ASCII encoded sequence of bytes.

  An that converts a sequence of Unicode characters into an ASCII encoded sequence of bytes.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` < 0.

  The method calculates the exact array size required by the method to store the resulting bytes, whereas the method calculates the maximum array size. The method generally allocates less memory, but the method generally executes faster.

  is a worst-case number, including the worst case for the currently selected . If you choose a replacement fallback with a potentially large string, can return large values.

  The method considers potential leftover surrogates from a previous encoding operation. As a result, if the object uses the default replacement fallback, or if a custom replacement fallback has been defined with a single possible fallback character, the method returns + 1. If the object uses a replacement fallback with more than one possible fallback character, the method returns n * ( + 1), where n is the maximum number of fallback characters.

  has no relation to . If your application needs a similar function to use with , it should use .

  GetMaxByteCount(N) is not necessarily the same value as N* GetMaxByteCount(1).

  Calculates the maximum number of bytes produced by encoding the specified number of characters.

  The maximum number of bytes produced by encoding the specified number of characters.

  The number of characters to encode. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` < 0.

  The method calculates the exact array size required by the method to store the resulting characters, whereas the method calculates the maximum array size. The method generally allocates less memory, while the method generally executes faster.

  retrieves a worst-case number, including the worst case for the currently selected . If a decoder fallback is present that has a maximum fallback length of n, the method returns n * .

  has no relation to . If your application needs a similar function to use with , it should use .

  GetMaxCharCount(N) is not necessarily the same value as N* GetMaxCharCount(1).

  Calculates the maximum number of characters produced by decoding the specified number of bytes.

  The maximum number of characters produced by decoding the specified number of bytes.

  The number of bytes to decode. 0
- Method
  System.String `` A array to decode as ASCII-encoded characters.

  Decodes the specified array of bytes as a string of ASCII-encoded characters.

  A containing the decoded representation of as ASCII-encoded characters.

  This method overrides .

  is . 0 1.0.5000.0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` `` `` is .

  < 0.

  -or-

  < 0.

  -or-

  (.Length - ) < .

  The byte array containing the sequence of bytes to decode.

  Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, the application should use the or the provided by the method or the method, respectively.

  does not provide error detection. Any byte greater than hexadecimal 0x7F is decoded as the Unicode question mark ("?").

  For security reasons, your application is recommended to use , , or and enable error detection.

  Decodes a range of bytes from a byte array into a string.

  A containing the results of decoding the specified sequence of bytes.

  The byte array containing the sequence of bytes to decode. The index of the first byte to decode. The number of bytes to decode. 0
- Property
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Boolean To be added.

  Instead of using the property to determine the size of a byte array for encoding operations and the size of a character array for decoding operations (for example, so that the size of the byte array is * the number of characters to be encoded), you should call the or method for encoding operations and the or method for decoding operations. These methods takes the object's replacement fallback strategy into account when calculating the required array size.

  Gets a value indicating whether the current encoding uses single-byte code points.

0