public class ASCIIEncoding : Encoding
Object
Encoding
ASCIIEncoding
mscorlib
BCL
Represents an ASCII character implementation of Encoding .
ASCIIEncoding encodes characters as single 7-bit ASCII characters. This encoding supports Unicode code points between U+0000 and U+007F, inclusive.[Note: The limited range of code points supported by ASCIIEncoding makes ASCII inadequate for many internationalized applications. UTF8Encoding and UnicodeEncoding provide encodings that are more suitable for internationalized applications.]
System.Text Namespace
ASCIIEncoding Constructors
ASCIIEncoding Methods
ASCIIEncoding.GetByteCount(char[], int, int) Method
ASCIIEncoding.GetByteCount(System.String) Method
ASCIIEncoding.GetBytes(System.String, int, int, byte[], int) Method
ASCIIEncoding.GetBytes(char[], int, int, byte[], int) Method
ASCIIEncoding.GetCharCount Method
ASCIIEncoding.GetChars Method
ASCIIEncoding.GetMaxByteCount Method
ASCIIEncoding.GetMaxCharCount Method
ASCIIEncoding.GetString(byte[], int, int) Method
ASCIIEncoding.GetString(byte[]) Method
public ASCIIEncoding();
Constructs a new instance of the ASCIIEncoding class.
System.Text.ASCIIEncoding Class, System.Text Namespace
public override int GetByteCount(char[] chars, int index, int count);
Determines the exact number of bytes required to encode the specified range of the specified array of characters as ASCII-encoded characters.
- chars
- A Char array containing the characters to encode as ASCII-encoded characters.
- index
- A Int32 that specifies the first index of chars to encode.
- count
- A Int32 that specifies the number of elements in chars to encode.
A Int32 containing the number of bytes required to encode the range in chars from index to index + count as ASCII-encoded characters.
Exception Type Condition ArgumentNullException chars is null
.ArgumentOutOfRangeException index < 0. -or-
count < 0.
-or-
index and count do not specify a valid range in chars (i.e. ( index + count) > chars.Length).
[Note: This method overrides System.Text.Encoding.GetByteCount(System.Char[]).]
System.Text.ASCIIEncoding Class, System.Text Namespace
public override int GetByteCount(string chars);
Determines the exact number of bytes required to encode the specified string as ASCII-encoded characters.
- chars
- A String to encode as ASCII-encoded characters.
A Int32 containing the number of bytes required to encode chars as ASCII-encoded characters.
Exception Type Condition ArgumentNullException chars is null
.
[Note: This method overrides System.Text.Encoding.GetByteCount(System.Char[]).]
System.Text.ASCIIEncoding Class, System.Text Namespace
public override int GetBytes(string chars, int charIndex, int charCount, byte[] bytes, int byteIndex);
Encodes the specified range of the specified string into the specified range of the specified array of bytes as ASCII-encoded characters.
- chars
- A String to encode as ASCII-encoded characters.
- charIndex
- A Int32 that specifies the first index of chars from which to encode.
- charCount
- A Int32 that specifies the number of elements in chars to encode.
- bytes
- A Byte array to encode.
- byteIndex
- A Int32 that specifies the first index of bytes to encode into.
A Int32 whose value equals the number of bytes encoded into bytes as ASCII-encoded characters.
Exception Type Condition ArgumentException (bytes.Length - byteIndex) < charCount.
ArgumentNullException chars is null
.-or-
bytes is
null
.
ArgumentOutOfRangeException charIndex < 0. -or-
charCount < 0.
-or-
(chars.Length - charIndex) < charCount.
-or-
byteIndex < 0.
-or-
byteIndex > bytes.Length.
Every Char object in chars that is encoded into bytes and that does not have an ASCII equivalent (i.e. has a code point greater than U+007f) will be encoded as a question mark ('?').[Note: This method overrides System.Text.Encoding.GetBytes(System.Char[]).]
System.Text.ASCIIEncoding Class, System.Text Namespace
public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex);
Encodes the specified range of the specified array of characters into the specified range of the specified array of bytes as ASCII-encoded characters.
- chars
- A Char array containing the characters to encode as ASCII-encoded characters.
- charIndex
- A Int32 that specifies the first index of chars to encode.
- charCount
- A Int32 that specifies the number of elements in chars to encode.
- bytes
- A Byte array to encode.
- byteIndex
- A Int32 that specifies the first index of bytes to encode into.
A Int32 whose value equals the number of bytes encoded into bytes as ASCII-encoded characters.
Exception Type Condition ArgumentException (bytes.Length - byteIndex) < charCount.
ArgumentNullException chars is null
.-or-
bytes is
null
.
ArgumentOutOfRangeException charIndex < 0. -or-
charCount < 0.
-or-
(chars.Length - charIndex) < charCount.
-or-
byteIndex < 0.
-or-
byteIndex > bytes.Length.
Every Char object in chars that is encoded into bytes and that does not have an ASCII equivalent (i.e. has a code point greater than U+007f) will be encoded as a question mark ('?').[Note: This method overrides System.Text.Encoding.GetBytes(System.Char[]).]
System.Text.ASCIIEncoding Class, System.Text Namespace
public override int GetCharCount(byte[] bytes, int index, int count);
Determines the exact number of characters that will be produced by decoding the specified range of the specified array of bytes as ASCII-encoded characters.
- bytes
- A Byte array to decode as ASCII-encoded characters.
- index
- A Int32 that specifies the first index in bytes to decode.
- count
- A Int32 that specifies the number elements in bytes to decode.
A Int32 whose value equals the number of characters a call to System.Text.ASCIIEncoding.GetChars(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32) will produce if presented with the specified range of bytes.[Note: This value does not take into account the state in which the current instance was left following the last call to System.Text.ASCIIEncoding.GetChars(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32). This contrasts with System.Text.Decoder.GetChars(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32) , which maintains state information across calls.]
Exception Type Condition ArgumentNullException bytes is null
.ArgumentOutOfRangeException index < 0. -or-
count < 0.
-or-
(bytes.Length - index) < count.
[Note: This method overrides System.Text.Encoding.GetCharCount(System.Byte[]).]
System.Text.ASCIIEncoding Class, System.Text Namespace
public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex);
Decodes the specified range of the specified array of bytes into the specified range of the specified array of characters as ASCII-encoded characters.
- bytes
- A Byte array to decode as ASCII-encoded characters.
- byteIndex
- A Int32 that specifies the first index of bytes from which to decode.
- byteCount
- A Int32 that specifies the number elements in bytes to decode.
- chars
- A Char array of characters to decode into.
- charIndex
- A Int32 that specifies the first index of chars to store the decoded bytes.
A Int32 whose value equals the number of characters decoded into chars as ASCII-encoded characters.
Exception Type Condition ArgumentException (chars.Length - charIndex) < byteCount.
ArgumentNullException bytes is null
.-or-
chars is
null
.
ArgumentOutOfRangeException byteIndex < 0. -or-
byteCount < 0.
-or-
(bytes.Length - byteIndex) < byteCount.
-or-
charIndex < 0.
-or-
charIndex > chars.Length.
[Note: This method overrides System.Text.Encoding.GetChars(System.Byte[]) .System.Text.ASCIIEncoding.GetChars(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32) can be used to determine the exact number of characters that will be produced for a specified range of bytes. Alternatively, the System.Text.ASCIIEncoding.GetMaxCharCount(System.Int32) method can be used to determine the maximum number of characters that will be produced for a specified number of bytes, regardless of the actual byte values.
]
System.Text.ASCIIEncoding Class, System.Text Namespace
public override int GetMaxByteCount(int charCount);
Returns the maximum number of bytes required to encode the specified number of characters as ASCII-encoded characters, regardless of the actual character values.
- charCount
- A Int32 that specifies the number of characters to encode as ASCII-encoded characters.
A Int32 containing the maximum number of bytes required to encode charCount characters as ASCII-encoded characters.
Exception Type Condition ArgumentOutOfRangeException charCount < 0.
[Note: This method overrides System.Text.Encoding.GetMaxByteCount(System.Int32) .Use this method to determine a minimum buffer size for byte arrays passed to the System.Text.ASCIIEncoding.GetBytes(System.Char[],System.Int32,System.Int32,System.Byte[],System.Int32) or System.Text.Encoding.GetBytes(System.Char[]) method for the current instance. Using this minimum buffer size can help ensure that buffer overflow exceptions do not occur.
]
System.Text.ASCIIEncoding Class, System.Text Namespace
public override int GetMaxCharCount(int byteCount);
Gets the maximum number of characters produced by decoding a specified number of bytes as ASCII-encoded characters, regardless of the actual byte values.
- byteCount
- A Int32 that specifies the number of bytes to decode as ASCII-encoded characters.
A Int32 containing the maximum number of characters that would be produced by decoding byteCount bytes as ASCII-encoded characters.
Exception Type Condition ArgumentOutOfRangeException byteCount < 0.
[Note: This method overrides System.Text.Encoding.GetMaxCharCount(System.Int32) .Use this method to determine the minimum buffer size for character arrays passed to the System.Text.ASCIIEncoding.GetChars(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32) or the System.Text.Encoding.GetChars(System.Byte[]) methods. Using this minimum buffer size can help ensure that buffer overflow exceptions do not occur.
]
System.Text.ASCIIEncoding Class, System.Text Namespace
public override string GetString(byte[] bytes, int byteIndex, int byteCount);
Decodes the specified range of the specified array of bytes as a string of ASCII-encoded characters.
- bytes
- A Byte array to decode as ASCII-encoded characters.
- byteIndex
- A Int32 that specifies the first index of bytes from which to decode.
- byteCount
- A Int32 that specifies the number of elements in bytes to decode.
A String object containing the decoded representation of the range in bytes from byteIndex to byteIndex + byteCount as ASCII-encoded characters.
Exception Type Condition ArgumentNullException bytes is null
.ArgumentOutOfRangeException byteIndex < 0. -or-
byteCount < 0.
-or-
(bytes.Length - byteIndex) < byteCount.
[Note: This method overrides System.Text.Encoding.GetString(System.Byte[]).]
System.Text.ASCIIEncoding Class, System.Text Namespace
public override string GetString(byte[] bytes);
Decodes the specified array of bytes as a string of ASCII-encoded characters.
- bytes
- A Byte array to decode as ASCII-encoded characters.
A String containing the decoded representation of bytes as ASCII-encoded characters.
Exception Type Condition ArgumentNullException bytes is null
.
[Note: This method overrides System.Text.Encoding.GetString(System.Byte[]).]
System.Text.ASCIIEncoding Class, System.Text Namespace