mscorlib(4.0.0.0) API with additions
System.Text.UnicodeEncoding Class Reference

Represents a UTF-16 encoding of Unicode characters. More...

Inheritance diagram for System.Text.UnicodeEncoding:
[legend]
Collaboration diagram for System.Text.UnicodeEncoding:
[legend]

Public Member Functions

 UnicodeEncoding ()
 Initializes a new instance of the T:System.Text.UnicodeEncoding class. More...
 
 UnicodeEncoding (bool bigEndian, bool byteOrderMark)
 Initializes a new instance of the T:System.Text.UnicodeEncoding class. Parameters specify whether to use the big endian byte order and whether the M:System.Text.UnicodeEncoding.GetPreamble method returns a Unicode byte order mark. More...
 
 UnicodeEncoding? (bool bigEndian, bool byteOrderMark, bool throwOnInvalidBytes)
 Initializes a new instance of the T:System.Text.UnicodeEncoding class. Parameters specify whether to use the big endian byte order, whether to provide a Unicode byte order mark, and whether to throw an exception when an invalid encoding is detected. More...
 
unsafe override int GetByteCount (char[] chars, int index, int count)
 Calculates the number of bytes produced by encoding a set of characters from the specified character array. More...
 
unsafe override int GetByteCount (string s)
 Calculates the number of bytes produced by encoding the characters in the specified string. More...
 
unsafe override int GetByteCount (char *chars, int count)
 Calculates the number of bytes produced by encoding a set of characters starting at the specified character pointer. More...
 
unsafe override int GetBytes (string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
 Encodes a set of characters from the specified T:System.String into the specified byte array. More...
 
unsafe override int GetBytes (char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
 Encodes a set of characters from the specified character array into the specified byte array. More...
 
unsafe override int GetBytes (char *chars, int charCount, byte *bytes, int byteCount)
 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. More...
 
unsafe override int GetCharCount (byte[] bytes, int index, int count)
 Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array. More...
 
unsafe override int GetCharCount (byte *bytes, int count)
 Calculates the number of characters produced by decoding a sequence of bytes starting at the specified byte pointer. More...
 
unsafe override int GetChars (byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
 Decodes a sequence of bytes from the specified byte array into the specified character array. More...
 
unsafe override int GetChars (byte *bytes, int byteCount, char *chars, int charCount)
 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. More...
 
unsafe override string GetString (byte[] bytes, int index, int count)
 Decodes a range of bytes from a byte array into a string. More...
 
override Encoder GetEncoder ()
 Obtains an encoder that converts a sequence of Unicode characters into a UTF-16 encoded sequence of bytes. More...
 
override System.Text.Decoder GetDecoder ()
 Obtains a decoder that converts a UTF-16 encoded sequence of bytes into a sequence of Unicode characters. More...
 
override byte [] GetPreamble ()
 Returns a Unicode byte order mark encoded in UTF-16 format, if the constructor for this instance requests a byte order mark. More...
 
override int GetMaxByteCount (int charCount)
 Calculates the maximum number of bytes produced by encoding the specified number of characters. More...
 
override int GetMaxCharCount (int byteCount)
 Calculates the maximum number of characters produced by decoding the specified number of bytes. More...
 
override bool Equals (object value)
 Determines whether the specified T:System.Object is equal to the current T:System.Text.UnicodeEncoding object. More...
 
override int GetHashCode ()
 Returns the hash code for the current instance. More...
 
- Public Member Functions inherited from System.Text.Encoding
virtual object Clone ()
 When overridden in a derived class, creates a shallow copy of the current T:System.Text.Encoding object. More...
 
virtual int GetByteCount (char[] chars)
 When overridden in a derived class, calculates the number of bytes produced by encoding all the characters in the specified character array. More...
 
virtual byte [] GetBytes (char[] chars)
 When overridden in a derived class, encodes all the characters in the specified character array into a sequence of bytes. More...
 
virtual byte [] GetBytes (char[] chars, int index, int count)
 When overridden in a derived class, encodes a set of characters from the specified character array into a sequence of bytes. More...
 
virtual byte [] GetBytes (string s)
 When overridden in a derived class, encodes all the characters in the specified string into a sequence of bytes. More...
 
virtual int GetCharCount (byte[] bytes)
 When overridden in a derived class, calculates the number of characters produced by decoding all the bytes in the specified byte array. More...
 
virtual char [] GetChars (byte[] bytes)
 When overridden in a derived class, decodes all the bytes in the specified byte array into a set of characters. More...
 
virtual char [] GetChars (byte[] bytes, int index, int count)
 When overridden in a derived class, decodes a sequence of bytes from the specified byte array into a set of characters. More...
 
unsafe string GetString (byte *bytes, int byteCount)
 When overridden in a derived class, decodes a specified number of bytes starting at a specified address into a string. More...
 
bool IsAlwaysNormalized ()
 Gets a value indicating whether the current encoding is always normalized, using the default normalization form. More...
 
virtual bool IsAlwaysNormalized (NormalizationForm form)
 When overridden in a derived class, gets a value indicating whether the current encoding is always normalized, using the specified normalization form. More...
 
virtual string GetString (byte[] bytes)
 When overridden in a derived class, decodes all the bytes in the specified byte array into a string. More...
 
override bool Equals (object value)
 Determines whether the specified T:System.Object is equal to the current instance. More...
 
override int GetHashCode ()
 Returns the hash code for the current instance. More...
 

Public Attributes

const int CharSize = 2
 Represents the Unicode character size in bytes. This field is a constant. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from System.Text.Encoding
static byte [] Convert (Encoding srcEncoding, Encoding dstEncoding, byte[] bytes)
 Converts an entire byte array from one encoding to another. More...
 
static byte [] Convert (Encoding srcEncoding, Encoding dstEncoding, byte[] bytes, int index, int count)
 Converts a range of bytes in a byte array from one encoding to another. More...
 
static void RegisterProvider (EncodingProvider provider)
 Registers an encoding provider. More...
 
static Encoding GetEncoding (int codepage)
 Returns the encoding associated with the specified code page identifier. More...
 
static Encoding GetEncoding (int codepage, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
 Returns the encoding associated with the specified code page identifier. Parameters specify an error handler for characters that cannot be encoded and byte sequences that cannot be decoded. More...
 
static Encoding GetEncoding (string name)
 Returns the encoding associated with the specified code page name. More...
 
static Encoding GetEncoding (string name, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
 Returns the encoding associated with the specified code page name. Parameters specify an error handler for characters that cannot be encoded and byte sequences that cannot be decoded. More...
 
static EncodingInfo [] GetEncodings ()
 Returns an array that contains all encodings. More...
 
- Protected Member Functions inherited from System.Text.Encoding
 Encoding ()
 Initializes a new instance of the T:System.Text.Encoding class. More...
 
 Encoding (int codePage)
 Initializes a new instance of the T:System.Text.Encoding class that corresponds to the specified code page. More...
 
 Encoding (int codePage, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
 Initializes a new instance of the T:System.Text.Encoding class that corresponds to the specified code page with the specified encoder and decoder fallback strategies. More...
 
- Properties inherited from System.Text.Encoding
virtual string BodyName [get]
 When overridden in a derived class, gets a name for the current encoding that can be used with mail agent body tags. More...
 
virtual string EncodingName [get]
 When overridden in a derived class, gets the human-readable description of the current encoding. More...
 
virtual string HeaderName [get]
 When overridden in a derived class, gets a name for the current encoding that can be used with mail agent header tags. More...
 
virtual string WebName [get]
 When overridden in a derived class, gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding. More...
 
virtual int WindowsCodePage [get]
 When overridden in a derived class, gets the Windows operating system code page that most closely corresponds to the current encoding. More...
 
virtual bool IsBrowserDisplay [get]
 When overridden in a derived class, gets a value indicating whether the current encoding can be used by browser clients for displaying content. More...
 
virtual bool IsBrowserSave [get]
 When overridden in a derived class, gets a value indicating whether the current encoding can be used by browser clients for saving content. More...
 
virtual bool IsMailNewsDisplay [get]
 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. More...
 
virtual bool IsMailNewsSave [get]
 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. More...
 
virtual bool IsSingleByte [get]
 When overridden in a derived class, gets a value indicating whether the current encoding uses single-byte code points. More...
 
EncoderFallback EncoderFallback [get, set]
 Gets or sets the T:System.Text.EncoderFallback object for the current T:System.Text.Encoding object. More...
 
DecoderFallback DecoderFallback [get, set]
 Gets or sets the T:System.Text.DecoderFallback object for the current T:System.Text.Encoding object. More...
 
bool IsReadOnly [get]
 When overridden in a derived class, gets a value indicating whether the current encoding is read-only. More...
 
static Encoding ASCII [get]
 Gets an encoding for the ASCII (7-bit) character set. More...
 
virtual int CodePage [get]
 When overridden in a derived class, gets the code page identifier of the current T:System.Text.Encoding. More...
 
static Encoding Default [get]
 Gets an encoding for the operating system's current ANSI code page. More...
 
static Encoding Unicode [get]
 Gets an encoding for the UTF-16 format using the little endian byte order. More...
 
static Encoding BigEndianUnicode [get]
 Gets an encoding for the UTF-16 format that uses the big endian byte order. More...
 
static Encoding UTF7 [get]
 Gets an encoding for the UTF-7 format. More...
 
static Encoding UTF8 [get]
 Gets an encoding for the UTF-8 format. More...
 
static Encoding UTF32 [get]
 Gets an encoding for the UTF-32 format using the little endian byte order. More...
 

Detailed Description

Represents a UTF-16 encoding of Unicode characters.

Definition at line 11 of file UnicodeEncoding.cs.

Constructor & Destructor Documentation

◆ UnicodeEncoding() [1/2]

System.Text.UnicodeEncoding.UnicodeEncoding ( )

Initializes a new instance of the T:System.Text.UnicodeEncoding class.

Definition at line 94 of file UnicodeEncoding.cs.

◆ UnicodeEncoding() [2/2]

System.Text.UnicodeEncoding.UnicodeEncoding ( bool  bigEndian,
bool  byteOrderMark 
)

Initializes a new instance of the T:System.Text.UnicodeEncoding class. Parameters specify whether to use the big endian byte order and whether the M:System.Text.UnicodeEncoding.GetPreamble method returns a Unicode byte order mark.

Parameters
bigEndiantrue to use the big endian byte order (most significant byte first), or false to use the little endian byte order (least significant byte first).
byteOrderMarktrue to specify that the M:System.Text.UnicodeEncoding.GetPreamble method returns a Unicode byte order mark; otherwise, false. See the Remarks section for more information.

Definition at line 105 of file UnicodeEncoding.cs.

Member Function Documentation

◆ Equals()

override bool System.Text.UnicodeEncoding.Equals ( object  value)

Determines whether the specified T:System.Object is equal to the current T:System.Text.UnicodeEncoding object.

Parameters
valueThe object to compare with the current object.
Returns
true if value is an instance of T:System.Text.UnicodeEncoding and is equal to the current object; otherwise, false.

Definition at line 1475 of file UnicodeEncoding.cs.

◆ GetByteCount() [1/3]

unsafe override int System.Text.UnicodeEncoding.GetByteCount ( char []  chars,
int  index,
int  count 
)
virtual

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

Parameters
charsThe character array containing the set of characters to encode.
indexThe index of the first character to encode.
countThe number of characters to encode.
Returns
The number of bytes produced by encoding the specified characters.
Exceptions
T:System.ArgumentNullExceptionchars is null (Nothing).
T:System.ArgumentOutOfRangeExceptionindex or count is less than zero.-or- index and count do not denote a valid range in chars .-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer.
T:System.ArgumentExceptionError detection is enabled, and chars contains an invalid sequence of characters.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.EncoderFallback is set to T:System.Text.EncoderExceptionFallback.

Implements System.Text.Encoding.

Definition at line 165 of file UnicodeEncoding.cs.

◆ GetByteCount() [2/3]

unsafe override int System.Text.UnicodeEncoding.GetByteCount ( string  s)
virtual

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

Parameters
sThe string that contains the set of characters to encode.
Returns
The number of bytes produced by encoding the specified characters.
Exceptions
T:System.ArgumentNullExceptions is null .
T:System.ArgumentOutOfRangeExceptionThe resulting number of bytes is greater than the maximum number that can be returned as an integer.
T:System.ArgumentExceptionError detection is enabled, and s contains an invalid sequence of characters.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.EncoderFallback is set to T:System.Text.EncoderExceptionFallback.

Reimplemented from System.Text.Encoding.

Definition at line 200 of file UnicodeEncoding.cs.

◆ GetByteCount() [3/3]

unsafe override int System.Text.UnicodeEncoding.GetByteCount ( char *  chars,
int  count 
)
virtual

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

Parameters
charsA pointer to the first character to encode.
countThe number of characters to encode.
Returns
The number of bytes produced by encoding the specified characters.
Exceptions
T:System.ArgumentNullExceptionchars is null .
T:System.ArgumentOutOfRangeExceptioncount is less than zero.-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer.
T:System.ArgumentExceptionError detection is enabled and chars contains an invalid sequence of characters.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.EncoderFallback is set to T:System.Text.EncoderExceptionFallback.

Reimplemented from System.Text.Encoding.

Definition at line 226 of file UnicodeEncoding.cs.

◆ GetBytes() [1/3]

unsafe override int System.Text.UnicodeEncoding.GetBytes ( string  s,
int  charIndex,
int  charCount,
byte []  bytes,
int  byteIndex 
)
virtual

Encodes a set of characters from the specified T:System.String into the specified byte array.

Parameters
sThe string containing the set of characters to encode.
charIndexThe index of the first character to encode.
charCountThe number of characters to encode.
bytesThe byte array to contain the resulting sequence of bytes.
byteIndexThe index at which to start writing the resulting sequence of bytes.
Returns
The actual number of bytes written into bytes .
Exceptions
T:System.ArgumentNullExceptions is null .-or- bytes is null (Nothing).
T:System.ArgumentOutOfRangeExceptioncharIndex or charCount or byteIndex is less than zero.-or- charIndex and charCount do not denote a valid range in chars .-or- byteIndex is not a valid index in bytes .
T:System.ArgumentExceptionError detection is enabled, and s contains an invalid sequence of characters.-or- bytes does not have enough capacity from byteIndex to the end of the array to accommodate the resulting bytes.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.EncoderFallback is set to T:System.Text.EncoderExceptionFallback.

Reimplemented from System.Text.Encoding.

Definition at line 259 of file UnicodeEncoding.cs.

◆ GetBytes() [2/3]

unsafe override int System.Text.UnicodeEncoding.GetBytes ( char []  chars,
int  charIndex,
int  charCount,
byte []  bytes,
int  byteIndex 
)
virtual

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

Parameters
charsThe character array containing the set of characters to encode.
charIndexThe index of the first character to encode.
charCountThe number of characters to encode.
bytesThe byte array to contain the resulting sequence of bytes.
byteIndexThe index at which to start writing the resulting sequence of bytes.
Returns
The actual number of bytes written into bytes .
Exceptions
T:System.ArgumentNullExceptionchars is null (Nothing).-or- bytes is null (Nothing).
T:System.ArgumentOutOfRangeExceptioncharIndex or charCount or byteIndex is less than zero.-or- charIndex and charCount do not denote a valid range in chars .-or- byteIndex is not a valid index in bytes .
T:System.ArgumentExceptionError detection is enabled, and chars contains an invalid sequence of characters.-or- bytes does not have enough capacity from byteIndex to the end of the array to accommodate the resulting bytes.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.EncoderFallback is set to T:System.Text.EncoderExceptionFallback.

Implements System.Text.Encoding.

Definition at line 312 of file UnicodeEncoding.cs.

◆ GetBytes() [3/3]

unsafe override int System.Text.UnicodeEncoding.GetBytes ( char *  chars,
int  charCount,
byte *  bytes,
int  byteCount 
)
virtual

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.

Parameters
charsA pointer to the first character to encode.
charCountThe number of characters to encode.
bytesA pointer to the location at which to start writing the resulting sequence of bytes.
byteCountThe maximum number of bytes to write.
Returns
The actual number of bytes written at the location indicated by the bytes parameter.
Exceptions
T:System.ArgumentNullExceptionchars is null (Nothing).-or- bytes is null (Nothing).
T:System.ArgumentOutOfRangeExceptioncharCount or byteCount is less than zero.
T:System.ArgumentExceptionError detection is enabled, and chars contains an invalid sequence of characters.-or- byteCount is less than the resulting number of bytes.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.EncoderFallback is set to T:System.Text.EncoderExceptionFallback.

Reimplemented from System.Text.Encoding.

Definition at line 367 of file UnicodeEncoding.cs.

◆ GetCharCount() [1/2]

unsafe override int System.Text.UnicodeEncoding.GetCharCount ( byte []  bytes,
int  index,
int  count 
)
virtual

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

Parameters
bytesThe byte array containing the sequence of bytes to decode.
indexThe index of the first byte to decode.
countThe number of bytes to decode.
Returns
The number of characters produced by decoding the specified sequence of bytes.
Exceptions
T:System.ArgumentNullExceptionbytes is null (Nothing).
T:System.ArgumentOutOfRangeExceptionindex or count is less than zero.-or- index and count do not denote a valid range in bytes .-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer.
T:System.ArgumentExceptionError detection is enabled, and bytes contains an invalid sequence of bytes.
T:System.Text.DecoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.DecoderFallback is set to T:System.Text.DecoderExceptionFallback.

Implements System.Text.Encoding.

Definition at line 395 of file UnicodeEncoding.cs.

◆ GetCharCount() [2/2]

unsafe override int System.Text.UnicodeEncoding.GetCharCount ( byte *  bytes,
int  count 
)
virtual

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

Parameters
bytesA pointer to the first byte to decode.
countThe number of bytes to decode.
Returns
The number of characters produced by decoding the specified sequence of bytes.
Exceptions
T:System.ArgumentNullExceptionbytes is null (Nothing).
T:System.ArgumentOutOfRangeExceptioncount is less than zero.-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer.
T:System.ArgumentExceptionError detection is enabled, and bytes contains an invalid sequence of bytes.
T:System.Text.DecoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.DecoderFallback is set to T:System.Text.DecoderExceptionFallback.

Reimplemented from System.Text.Encoding.

Definition at line 433 of file UnicodeEncoding.cs.

◆ GetChars() [1/2]

unsafe override int System.Text.UnicodeEncoding.GetChars ( byte []  bytes,
int  byteIndex,
int  byteCount,
char []  chars,
int  charIndex 
)
virtual

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

Parameters
bytesThe byte array containing the sequence of bytes to decode.
byteIndexThe index of the first byte to decode.
byteCountThe number of bytes to decode.
charsThe character array to contain the resulting set of characters.
charIndexThe index at which to start writing the resulting set of characters.
Returns
The actual number of characters written into chars .
Exceptions
T:System.ArgumentNullExceptionbytes is null (Nothing).-or- chars is null (Nothing).
T:System.ArgumentOutOfRangeExceptionbyteIndex or byteCount or charIndex is less than zero.-or- byteindex and byteCount do not denote a valid range in bytes .-or- charIndex is not a valid index in chars .
T:System.ArgumentExceptionError detection is enabled, and bytes contains an invalid sequence of bytes.-or- chars does not have enough capacity from charIndex to the end of the array to accommodate the resulting characters.
T:System.Text.DecoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.DecoderFallback is set to T:System.Text.DecoderExceptionFallback.

Implements System.Text.Encoding.

Definition at line 466 of file UnicodeEncoding.cs.

◆ GetChars() [2/2]

unsafe override int System.Text.UnicodeEncoding.GetChars ( byte *  bytes,
int  byteCount,
char *  chars,
int  charCount 
)
virtual

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.

Parameters
bytesA pointer to the first byte to decode.
byteCountThe number of bytes to decode.
charsA pointer to the location at which to start writing the resulting set of characters.
charCountThe maximum number of characters to write.
Returns
The actual number of characters written at the location indicated by the chars parameter.
Exceptions
T:System.ArgumentNullExceptionbytes is null (Nothing).-or- chars is null (Nothing).
T:System.ArgumentOutOfRangeExceptionbyteCount or charCount is less than zero.
T:System.ArgumentExceptionError detection is enabled, and bytes contains an invalid sequence of bytes.-or- charCount is less than the resulting number of characters.
T:System.Text.DecoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.DecoderFallback is set to T:System.Text.DecoderExceptionFallback.

Reimplemented from System.Text.Encoding.

Definition at line 521 of file UnicodeEncoding.cs.

◆ GetDecoder()

override System.Text.Decoder System.Text.UnicodeEncoding.GetDecoder ( )
virtual

Obtains a decoder that converts a UTF-16 encoded sequence of bytes into a sequence of Unicode characters.

Returns
A T:System.Text.Decoder that converts a UTF-16 encoded sequence of bytes into a sequence of Unicode characters.

Reimplemented from System.Text.Encoding.

Definition at line 1388 of file UnicodeEncoding.cs.

◆ GetEncoder()

override Encoder System.Text.UnicodeEncoding.GetEncoder ( )
virtual

Obtains an encoder that converts a sequence of Unicode characters into a UTF-16 encoded sequence of bytes.

Returns
A T:System.Text.Encoder object that converts a sequence of Unicode characters into a UTF-16 encoded sequence of bytes.

Reimplemented from System.Text.Encoding.

Definition at line 1380 of file UnicodeEncoding.cs.

◆ GetHashCode()

override int System.Text.UnicodeEncoding.GetHashCode ( )

Returns the hash code for the current instance.

Returns
The hash code for the current T:System.Text.UnicodeEncoding object.

Definition at line 1492 of file UnicodeEncoding.cs.

◆ GetMaxByteCount()

override int System.Text.UnicodeEncoding.GetMaxByteCount ( int  charCount)
virtual

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

Parameters
charCountThe number of characters to encode.
Returns
The maximum number of bytes produced by encoding the specified number of characters.
Exceptions
T:System.ArgumentOutOfRangeExceptioncharCount is less than zero.-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.EncoderFallback is set to T:System.Text.EncoderExceptionFallback.

Implements System.Text.Encoding.

Definition at line 1425 of file UnicodeEncoding.cs.

◆ GetMaxCharCount()

override int System.Text.UnicodeEncoding.GetMaxCharCount ( int  byteCount)
virtual

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

Parameters
byteCountThe number of bytes to decode.
Returns
The maximum number of characters produced by decoding the specified number of bytes.
Exceptions
T:System.ArgumentOutOfRangeExceptionbyteCount is less than zero.-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer.
T:System.Text.DecoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.DecoderFallback is set to T:System.Text.DecoderExceptionFallback.

Implements System.Text.Encoding.

Definition at line 1452 of file UnicodeEncoding.cs.

◆ GetPreamble()

override byte [] System.Text.UnicodeEncoding.GetPreamble ( )
virtual

Returns a Unicode byte order mark encoded in UTF-16 format, if the constructor for this instance requests a byte order mark.

Returns
A byte array containing the Unicode byte order mark, if the T:System.Text.UnicodeEncoding object is configured to supply one. Otherwise, this method returns a zero-length byte array.

Reimplemented from System.Text.Encoding.

Definition at line 1396 of file UnicodeEncoding.cs.

◆ GetString()

unsafe override string System.Text.UnicodeEncoding.GetString ( byte []  bytes,
int  index,
int  count 
)
virtual

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

Parameters
bytesThe byte array containing the sequence of bytes to decode.
indexThe index of the first byte to decode.
countThe number of bytes to decode.
Returns
A T:System.String object containing the results of decoding the specified sequence of bytes.
Exceptions
T:System.ArgumentNullExceptionbytes is null (Nothing).
T:System.ArgumentOutOfRangeExceptionindex or count is less than zero.-or- index and count do not denote a valid range in bytes .
T:System.ArgumentExceptionError detection is enabled, and bytes contains an invalid sequence of bytes.
T:System.Text.DecoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoding.DecoderFallback is set to T:System.Text.DecoderExceptionFallback.

Reimplemented from System.Text.Encoding.

Definition at line 550 of file UnicodeEncoding.cs.

◆ UnicodeEncoding?()

System.Text.UnicodeEncoding.UnicodeEncoding? ( bool  bigEndian,
bool  byteOrderMark,
bool  throwOnInvalidBytes 
)

Initializes a new instance of the T:System.Text.UnicodeEncoding class. Parameters specify whether to use the big endian byte order, whether to provide a Unicode byte order mark, and whether to throw an exception when an invalid encoding is detected.

Parameters
bigEndiantrue to use the big endian byte order (most significant byte first); false to use the little endian byte order (least significant byte first).
byteOrderMarktrue to specify that the M:System.Text.UnicodeEncoding.GetPreamble method returns a Unicode byte order mark; otherwise, false. See the Remarks section for more information.
throwOnInvalidBytestrue to specify that an exception should be thrown when an invalid encoding is detected; otherwise, false.

Definition at line 118 of file UnicodeEncoding.cs.

Member Data Documentation

◆ CharSize

const int System.Text.UnicodeEncoding.CharSize = 2

Represents the Unicode character size in bytes. This field is a constant.

Definition at line 90 of file UnicodeEncoding.cs.


The documentation for this class was generated from the following file: