Decoder.Convert Method (Byte*, Int32, Char*, Int32, Boolean, Int32, Int32, Boolean)
Converts a buffer of encoded bytes to UTF-16 encoded characters and stores the result in another buffer.
This API is not CLS-compliant.
Assembly: mscorlib (in mscorlib.dll)
[SecurityCriticalAttribute] [CLSCompliantAttribute(false)] [ComVisibleAttribute(false)] public virtual unsafe void Convert( byte* bytes, int byteCount, char* chars, int charCount, bool flush, out int bytesUsed, out int charsUsed, out bool completed )
The address of a buffer that contains the byte sequences to convert.
The number of bytes in bytes to convert.
The address of a buffer to store the converted characters.
The maximum number of characters in chars to use in the conversion.
true to indicate no further data is to be converted; otherwise, false.
When this method returns, contains the number of bytes that were produced by the conversion. This parameter is passed uninitialized.
When this method returns, contains the number of characters from chars that were used in the conversion. This parameter is passed uninitialized.
When this method returns, contains true if all the characters specified by byteCount were converted; otherwise, false. This parameter is passed uninitialized.
chars or bytes is null (Nothing).
charCount or byteCount is less than zero.
The output buffer is too small to contain any of the converted input. The output buffer should be greater than or equal to the size indicated by the GetCharCount method.
Remember that the Decoder object saves state between calls to . When the application is done with a stream of data, it should set the flush parameter to true to make sure that the state information is flushed. With this setting, the decoder ignores invalid bytes at the end of the data block and clears the internal buffer. Any remaining processed data that is part of a logical unit, such as the high surrogate of a surrogate pair, is converted according to the current fallback settings.
The Convert method is designed to be used in a loop to decode an arbitrary amount of input, such as data read from a file or stream. It stores the output of the decoding operation in a fixed-size buffer. GetChars will throw an exception if the output buffer isn't large enough, but will fill as much space as possible and return the bytes read and chars written. Also see the Encoding.GetChars topic for more comments.
The completed output parameter indicates whether all the data in the input buffer was converted and stored in the output buffer. This parameter is set to false if the number of bytes specified by the byteCount parameter cannot be converted without exceeding the number of characters specified by the charCount parameter. In that situation, the application should use the contents of the output buffer or provide a new output buffer, increment the bytes parameter by the number of bytes specified by the bytesUsed parameter, then call the Convert method again to process the remaining input.
The completed parameter can also be set to false, even though the bytesUsed and byteCount parameters are equal. This situation occurs if there is still data in the Decoder object that has not been stored in the bytes buffer.
Requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Available since 2.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0