UTF7Encoding::GetChars Method (Byte*, Int32, Char*, Int32)
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.
This API is not CLS-compliant.
Assembly: mscorlib (in mscorlib.dll)
public: [SecurityCriticalAttribute] [CLSCompliantAttribute(false)] [ComVisibleAttribute(false)] virtual int GetChars( unsigned char* bytes, int byteCount, wchar_t* chars, int charCount ) override
Parameters
- bytes
-
Type:
System::Byte*
A pointer to the first byte to decode.
- byteCount
-
Type:
System::Int32
The number of bytes to decode.
- chars
-
Type:
System::Char*
A pointer to the location at which to start writing the resulting set of characters.
- charCount
-
Type:
System::Int32
The maximum number of characters to write.
Return Value
Type: System::Int32The actual number of characters written at the location indicated by chars.
| Exception | Condition |
|---|---|
| ArgumentNullException | bytes is null (Nothing). -or- chars is null (Nothing). |
| ArgumentOutOfRangeException | byteCount or charCount is less than zero. |
| ArgumentException | charCount is less than the resulting number of characters. |
| DecoderFallbackException | A fallback occurred (see Character Encoding in the .NET Framework for complete explanation) -and- DecoderFallback is set to DecoderExceptionFallback. |
To calculate the exact array size required by GetChars to store the resulting characters, use GetCharCount. To calculate the maximum array size, the application should use GetMaxCharCount. The GetCharCount method generally allows allocation of less memory, while the GetMaxCharCount method generally executes faster.
Data to be converted, such as data read from a stream, might 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 Decoder or the Encoder provided by the GetDecoder method or the GetEncoder method, respectively.
Note |
|---|
UTF7Encoding does not provide error detection. When invalid bytes are encountered, UTF7Encoding generally emits the invalid bytes. If a byte is larger than hexadecimal 0x7F, the byte value is zero-extended into a Unicode character, the result is stored in the chars array, and any shift sequence is terminated. For example, if the byte to encode is hexadecimal 0x81, the resulting character is U+0081. For security reasons, your applications are recommended to use UTF8Encoding, UnicodeEncoding, or UTF32Encoding and enable error detection. |
Requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Available since 10
.NET Framework
Available since 2.0
