
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Encoding Chunks of Data
|
85
tempBuffer.CopyTo(outputBytes, 0);
}
// Copy the input buffer into our byte[] buffer
// where the last copy left off.
int charsUsed;
int bytesUsed;
bool completed;
encoder.Convert(inputBuffer, 0, inputBuffer.Length, outputBytes,
startPos * 2,
inputBuffer.Length * 2, isLastBuffer,
out charsUsed,
out bytesUsed, out completed);
// Increment the starting position in the byte[]
// in which to add the next input buffer.
startPos += inputBuffer.Length;
}
// Display data.
Console.WriteLine("isLastBuffer == " + isLastBuffer.ToString( ));
foreach (byte b in outputBytes)
{
if (b > 0)
Console.Write(b.ToString( ) + " -- ");
}
Console.WriteLine( );
}
The highlighted lines indicate the changes that are needed. These changes simply
take into account the larger size of the Unicode-encoded characters that will be
placed in the
outputBytes buffer.
See Also
See the “Encoder.Convert Method” topic in the MSDN documentation.