Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Text.​Encoding
Assembly: System.Runtime
Inheritance: object → Encoding
Represents a character encoding.
Properties
public
string
BodyName
When overridden in a derived class, gets a name for the current encoding that can be used with mail agent body tags.
public
int
CodePage
When overridden in a derived class, gets the code page identifier of the current <see cref="T:System.Text.Encoding" /> .
public
DecoderFallback
DecoderFallback
Gets or sets the <see cref="T:System.Text.DecoderFallback" /> object for the current <see cref="T:System.Text.Encoding" /> object.
public
EncoderFallback
EncoderFallback
Gets or sets the <see cref="T:System.Text.EncoderFallback" /> object for the current <see cref="T:System.Text.Encoding" /> object.
public
string
EncodingName
When overridden in a derived class, gets the human-readable description of the current encoding.
public
string
HeaderName
When overridden in a derived class, gets a name for the current encoding that can be used with mail agent header tags.
public
bool
IsBrowserDisplay
When overridden in a derived class, gets a value indicating whether the current encoding can be used by browser clients for displaying content.
public
bool
IsBrowserSave
When overridden in a derived class, gets a value indicating whether the current encoding can be used by browser clients for saving content.
public
bool
IsMailNewsDisplay
When overridden in a derived class, gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
public
bool
IsMailNewsSave
When overridden in a derived class, gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
public
bool
IsReadOnly
When overridden in a derived class, gets a value indicating whether the current encoding is read-only.
public
bool
IsSingleByte
When overridden in a derived class, gets a value indicating whether the current encoding uses single-byte code points.
public
ReadOnlySpan`1
Preamble
When overridden in a derived class, returns a span containing the sequence of bytes that specifies the encoding used.
public
string
WebName
When overridden in a derived class, gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
public
int
WindowsCodePage
When overridden in a derived class, gets the Windows operating system code page that most closely corresponds to the current encoding.
Methods
public
object
Clone​() Returns A copy of the current <see cref="T:System.Text.Encoding" /> object.
When overridden in a derived class, creates a shallow copy of the current <see cref="T:System.Text.Encoding" /> object.
public
bool
Equals​(object value)
value
The <see cref="T:System.Object" /> to compare with the current instance.
Returns <see langword="true" /> if <paramref name="value" /> is an instance of <see cref="T:System.Text.Encoding" /> and is equal to the current instance; otherwise, <see langword="false" /> .
Determines whether the specified <see cref="T:System.Object" /> is equal to the current instance.
public
int
GetByteCount​(Char* chars,
int count)
chars
A pointer to the first character to encode.
count
The number of characters to encode.
Returns The number of bytes produced by encoding the specified characters.
When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters starting at the specified character pointer.
public
int
GetByteCount​(char[] chars)
chars
The character array containing the characters to encode.
Returns The number of bytes produced by encoding all the characters in the specified character array.
When overridden in a derived class, calculates the number of bytes produced by encoding all the characters in the specified character array.
public
int
GetByteCount​(char[] chars,
int index,
int count)
chars
The character array containing the set of characters to encode.
index
The index of the first character to encode.
count
The number of characters to encode.
Returns The number of bytes produced by encoding the specified characters.
When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters from the specified character array.
public
int
GetByteCount​(string s)
s
The string containing the set of characters to encode.
Returns The number of bytes produced by encoding the specified characters.
When overridden in a derived class, calculates the number of bytes produced by encoding the characters in the specified string.
public
int
GetByteCount​(string s,
int index,
int count)
s
The string containing the set of characters to encode.
index
The index of the first character to encode.
count
The number of characters to encode.
Returns The number of bytes produced by encoding the string.
When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters from the specified string.
public
int
GetBytes​(Char* chars,
int charCount,
Byte* bytes,
int byteCount)
chars
A pointer to the first character to encode.
charCount
The number of characters to encode.
bytes
A pointer to the location at which to start writing the resulting sequence of bytes.
byteCount
The maximum number of bytes to write.
Returns The actual number of bytes written at the location indicated by the <paramref name="bytes" /> parameter.
When overridden in a derived class, 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.
public
byte[]
GetBytes​(char[] chars)
chars
The character array containing the characters to encode.
Returns A byte array containing the results of encoding the specified set of characters.
When overridden in a derived class, encodes all the characters in the specified character array into a sequence of bytes.
public
byte[]
GetBytes​(char[] chars,
int index,
int count)
chars
The character array containing the set of characters to encode.
index
The index of the first character to encode.
count
The number of characters to encode.
Returns A byte array containing the results of encoding the specified set of characters.
When overridden in a derived class, encodes a set of characters from the specified character array into a sequence of bytes.
public
int
GetBytes​(char[] chars,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex)
chars
The character array containing the set of characters to encode.
charIndex
The index of the first character to encode.
charCount
The number of characters to encode.
bytes
The byte array to contain the resulting sequence of bytes.
byteIndex
The index at which to start writing the resulting sequence of bytes.
Returns The actual number of bytes written into <paramref name="bytes" /> .
When overridden in a derived class, encodes a set of characters from the specified character array into the specified byte array.
public
byte[]
GetBytes​(string s)
s
The string containing the characters to encode.
Returns A byte array containing the results of encoding the specified set of characters.
When overridden in a derived class, encodes all the characters in the specified string into a sequence of bytes.
public
byte[]
GetBytes​(string s,
int index,
int count)
s
The string containing the characters to encode.
index
The index inside the string to start the encoding from.
count
The number of characters to encode.
Returns A byte array containing the results of encoding the specified set of characters.
When overridden in a derived class, encodes into an array of bytes the number of characters specified by <paramref name="count" /> in the specified string, starting from the specified <paramref name="index" /> .
public
int
GetBytes​(string s,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex)
s
The string containing the set of characters to encode.
charIndex
The index of the first character to encode.
charCount
The number of characters to encode.
bytes
The byte array to contain the resulting sequence of bytes.
byteIndex
The index at which to start writing the resulting sequence of bytes.
Returns The actual number of bytes written into <paramref name="bytes" /> .
When overridden in a derived class, encodes a set of characters from the specified string into the specified byte array.
public
int
GetCharCount​(Byte* bytes,
int count)
bytes
A pointer to the first byte to decode.
count
The number of bytes to decode.
Returns The number of characters produced by decoding the specified sequence of bytes.
When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes starting at the specified byte pointer.
public
int
GetCharCount​(byte[] bytes)
bytes
The byte array containing the sequence of bytes to decode.
Returns The number of characters produced by decoding the specified sequence of bytes.
When overridden in a derived class, calculates the number of characters produced by decoding all the bytes in the specified byte array.
public
int
GetCharCount​(byte[] bytes,
int index,
int count)
bytes
The byte array containing the sequence of bytes to decode.
index
The index of the first byte to decode.
count
The number of bytes to decode.
Returns The number of characters produced by decoding the specified sequence of bytes.
When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.
public
int
GetChars​(Byte* bytes,
int byteCount,
Char* chars,
int charCount)
bytes
A pointer to the first byte to decode.
byteCount
The number of bytes to decode.
chars
A pointer to the location at which to start writing the resulting set of characters.
charCount
The maximum number of characters to write.
Returns The actual number of characters written at the location indicated by the <paramref name="chars" /> parameter.
When overridden in a derived class, 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.
public
char[]
GetChars​(byte[] bytes)
bytes
The byte array containing the sequence of bytes to decode.
Returns A character array containing the results of decoding the specified sequence of bytes.
When overridden in a derived class, decodes all the bytes in the specified byte array into a set of characters.
public
char[]
GetChars​(byte[] bytes,
int index,
int count)
bytes
The byte array containing the sequence of bytes to decode.
index
The index of the first byte to decode.
count
The number of bytes to decode.
Returns A character array containing the results of decoding the specified sequence of bytes.
When overridden in a derived class, decodes a sequence of bytes from the specified byte array into a set of characters.
public
int
GetChars​(byte[] bytes,
int byteIndex,
int byteCount,
char[] chars,
int charIndex)
bytes
The byte array containing the sequence of bytes to decode.
byteIndex
The index of the first byte to decode.
byteCount
The number of bytes to decode.
chars
The character array to contain the resulting set of characters.
charIndex
The index at which to start writing the resulting set of characters.
Returns The actual number of characters written into <paramref name="chars" /> .
When overridden in a derived class, decodes a sequence of bytes from the specified byte array into the specified character array.
public
Decoder
GetDecoder​() Returns A <see cref="T:System.Text.Decoder" /> that converts an encoded sequence of bytes into a sequence of characters.
When overridden in a derived class, obtains a decoder that converts an encoded sequence of bytes into a sequence of characters.
public
Encoder
GetEncoder​() Returns A <see cref="T:System.Text.Encoder" /> that converts a sequence of Unicode characters into an encoded sequence of bytes.
When overridden in a derived class, obtains an encoder that converts a sequence of Unicode characters into an encoded sequence of bytes.
public
int
GetHashCode​() Returns The hash code for the current instance.
Returns the hash code for the current instance.
public
int
GetMaxByteCount​(int charCount)
charCount
The number of characters to encode.
Returns The maximum number of bytes produced by encoding the specified number of characters.
When overridden in a derived class, calculates the maximum number of bytes produced by encoding the specified number of characters.
public
int
GetMaxCharCount​(int byteCount)
byteCount
The number of bytes to decode.
Returns The maximum number of characters produced by decoding the specified number of bytes.
When overridden in a derived class, calculates the maximum number of characters produced by decoding the specified number of bytes.
public
byte[]
GetPreamble​() Returns A byte array containing a sequence of bytes that specifies the encoding used.
-or-
A byte array of length zero, if a preamble is not required.
When overridden in a derived class, returns a sequence of bytes that specifies the encoding used.
public
string
GetString​(Byte* bytes,
int byteCount)
bytes
A pointer to a byte array.
byteCount
The number of bytes to decode.
Returns A string that contains the results of decoding the specified sequence of bytes.
When overridden in a derived class, decodes a specified number of bytes starting at a specified address into a string.
public
string
GetString​(byte[] bytes)
bytes
The byte array containing the sequence of bytes to decode.
Returns A string that contains the results of decoding the specified sequence of bytes.
When overridden in a derived class, decodes all the bytes in the specified byte array into a string.
public
string
GetString​(byte[] bytes,
int index,
int count)
bytes
The byte array containing the sequence of bytes to decode.
index
The index of the first byte to decode.
count
The number of bytes to decode.
Returns A string that contains the results of decoding the specified sequence of bytes.
When overridden in a derived class, decodes a sequence of bytes from the specified byte array into a string.
public
bool
IsAlwaysNormalized​() Returns <see langword="true" /> if the current <see cref="T:System.Text.Encoding" /> is always normalized; otherwise, <see langword="false" /> . The default is <see langword="false" /> .
Gets a value indicating whether the current encoding is always normalized, using the default normalization form.
public
bool
IsAlwaysNormalized​(NormalizationForm form)
form
One of the <see cref="T:System.Text.NormalizationForm" /> values.
Returns <see langword="true" /> if the current <see cref="T:System.Text.Encoding" /> object is always normalized using the specified <see cref="T:System.Text.NormalizationForm" /> value; otherwise, <see langword="false" /> . The default is <see langword="false" /> .
When overridden in a derived class, gets a value indicating whether the current encoding is always normalized, using the specified normalization form.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .
public
string
ToString​()
Inherited from object
Returns A string that represents the current object.
Returns a string that represents the current object.