Share via


Convert Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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

Namespace:  System.Text
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public MustOverride Sub Convert ( _
    bytes As Byte(), _
    byteIndex As Integer, _
    byteCount As Integer, _
    chars As Char(), _
    charIndex As Integer, _
    charCount As Integer, _
    flush As Boolean, _
    <OutAttribute> ByRef bytesUsed As Integer, _
    <OutAttribute> ByRef charsUsed As Integer, _
    <OutAttribute> ByRef completed As Boolean _
)
public abstract void Convert(
    byte[] bytes,
    int byteIndex,
    int byteCount,
    char[] chars,
    int charIndex,
    int charCount,
    bool flush,
    out int bytesUsed,
    out int charsUsed,
    out bool completed
)
public:
virtual void Convert(
    array<unsigned char>^ bytes, 
    int byteIndex, 
    int byteCount, 
    array<wchar_t>^ chars, 
    int charIndex, 
    int charCount, 
    bool flush, 
    [OutAttribute] int% bytesUsed, 
    [OutAttribute] int% charsUsed, 
    [OutAttribute] bool% completed
) abstract
abstract Convert : 
        bytes:byte[] * 
        byteIndex:int * 
        byteCount:int * 
        chars:char[] * 
        charIndex:int * 
        charCount:int * 
        flush:bool * 
        bytesUsed:int byref * 
        charsUsed:int byref * 
        completed:bool byref -> unit 
public abstract function Convert(
    bytes : byte[], 
    byteIndex : int, 
    byteCount : int, 
    chars : char[], 
    charIndex : int, 
    charCount : int, 
    flush : boolean, 
    bytesUsed : int, 
    charsUsed : int, 
    completed : boolean
)

Parameters

  • charCount
    Type: System. . :: . .Int32
    The maximum number of elements of chars to use in the conversion.
  • bytesUsed
    Type: System. . :: . .Int32%
    When this method returns, contains the number of bytes that were used in the conversion. This parameter is passed uninitialized.
  • charsUsed
    Type: System. . :: . .Int32%
    When this method returns, contains the number of characters from chars that were produced by the conversion. This parameter is passed uninitialized.
  • completed
    Type: System. . :: . .Boolean%
    When this method returns, contains true if all the characters specified by byteCount were converted; otherwise, false. This parameter is passed uninitialized.

Remarks

Remember that the Decoder object saves state between calls to Convert. 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 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.

.NET Framework Security

See Also

Reference

Decoder Class

System.Text Namespace