Decoder: Convert

Convert

Converts an array of encoded bytes to UTF-16 encoded characters and stores the result in a character array.



 Public Sub Convert(
	  ByRef Bytes ( ) As Byte,
	  ByVal ByteIndex As Long,
	  ByVal ByteCount As Long,
	  ByRef Chars ( ) As Integer,
	  ByVal CharIndex As Long,
	  ByVal CharCount As Long,
	  ByVal Flush As Boolean,
	  ByRef BytesUsed As Long,
	  ByRef CharsUsed As Long,
	  ByRef Completed As Boolean )

Parameters

Bytes
[ByRef] Byte. The byte array to convert.
ByteIndex
[ByVal] Long. The starting position to convert in Bytes.
ByteCount
[ByVal] Long. The number of bytes to be converted.
Chars
[ByRef] Integer. The char array to receive the converted characters.
CharIndex
[ByVal] Long. The starting position to place converted characters.
CharCount
[ByVal] Long. The maximum number of element of chars to use in the conversion.
Flush
[ByVal] Boolean. True to indicate that no further data is to be converted; otherwise, False.
BytesUsed
[ByRef] Long. When this method returns, contains the number of bytes that were used in the conversion. This parameter is passed uninitialized.
CharsUsed
[ByRef] Long. When this method returns, contains the number of characters from chars that were produced by the conversion. This parameter is passed uninitialized.
Completed
[ByRef] Boolean. When this method returns, contains True if all the characters specified by byteCount were converted; otherwise, False. This parameter is passed uninitialized.

Remarks

The Convert method will attempt to convert up to ByteCount bytes but no more than would generate CharCount characters.

An optimized implementation would attempt to convert as many bytes as are available to create CharCount characters. The default implementation simply tries to find a number of byte that when converted will fit in CharCount characters. If there are too many characters to fit then the number of bytes used to calculate the number of characters is halved. This does not lead to an optimal solution as CharCount will usually not be achieved.

See Also

Project CorLib Overview

Class Decoder Overview