NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

UTF8Encoding.GetBytes

Encodes a range of an array of characters into an array of bytes.

[Visual Basic]
Overrides Public Function GetBytes( _
   ByVal chars() As Char, _
   ByVal charIndex As Integer, _
   ByVal charCount As Integer, _
   ByVal bytes() As Byte, _
   ByVal byteIndex As Integer _
) As Integer
[C#]
public override int GetBytes(
   char[] chars,
   int charIndex,
   int charCount,
   byte[] bytes,
   int byteIndex
);
[C++]
public: override int GetBytes(
   __wchar_t* chars[],
   int charIndex,
   int charCount,
   unsigned char* bytes[],
   int byteIndex
);
[JScript]
public override function GetBytes(
   chars : Char[],
   charIndex : int,
   charCount : int,
   bytes : Byte[],
   byteIndex : int
) : int;

Parameters

chars
The character array to encode.
charIndex
The starting index of the character array to encode.
charCount
The number of characters to encode.
bytes
The byte array to encode into.
byteIndex
The starting index of the resulting encoding in the byte array.

Return Value

The number of bytes stored into the byte array.

Exceptions

Exception Type Condition
ArgumentNullException The chars or bytes parameter is a null reference (in Visual Basic Nothing).
ArgumentOutOfRangeException The charIndex, charCount or byteIndex parameter is less than zero.

The sum of the charIndex and charCount parameters is greater than the length of the character array.

The byteIndex parameter is greater than the length of the byte array.

Encoding.BufferOverflow The the byteIndex parameter is equal to the length of the byte array.

No bytes have been stored into the byte array.

ArgumentException Argument_InvalidHighSurrogate.

Argument_InvalidLowSurrogate.

Remarks

Overrides GetBytes.

GetByteCount can be used to determine the exact number of bytes that will be produced for a specified range of characters. Alternatively, GetMaxByteCount can be used to determine the maximum number of bytes that will be produced for a specified number of characters, regardless of the actual character values.

See Also

UTF8Encoding Class | UTF8Encoding Members | System.Text Namespace | GetByteCount | GetMaxByteCount | GetBytes