private char ReadOneChar( TextReader reader )
{
// NOTE: the handling of multi-byte encodings is probably not the most
// efficient here ...
bool completed = false;
int byteIndex = 0;
while ( !completed )
{
byteDecodingBuffer[ byteIndex ] = (byte)ReadOneByte( reader );
byteIndex++;
int usedBytes;
int usedChars;
byteToCharDecoder.Convert(
byteDecodingBuffer, 0, byteIndex,
charDecodingBuffer, 0, 1,
true,
out usedBytes,
out usedChars,
out completed );
if ( completed && ( usedBytes != byteIndex || usedChars != 1 ) )
{
throw new RtfMultiByteEncodingException( Strings.InvalidMultiByteEncoding(
byteDecodingBuffer, byteIndex, encoding ) );
}
}
char character = charDecodingBuffer[ 0 ];
return character;
}