Microsoft KB Archive/298384

= BUG: Error &quot;CharConversionException: OuputBuffer Too Small&quot; =

Q298384

-

The information in this article applies to:


 * Microsoft virtual machine

-

SYMPTOMS
When you use a multi-byte character set (MBCS) and Unicode conversions, you may receive the following error message:

CharConversionException: OutputBuffer too small.

CAUSE
The Java java.io.OutputStreamWriter class throws this exception instead of flushing the internal buffer.

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

Code to Reproduce Behavior
To reproduce the error, include and run the following code in your project:   ByteArrayOutputStream bos; OutputStreamWriter osw; MyOutputStreamWriter myosw; byte[] array;  // Use the built-in unfixed class. bos = new ByteArrayOutputStream; osw = new OutputStreamWriter(bos, &quot;UTF8&quot;); osw.write('a'); try {     for(int count = 0; count < 10000; ++count) {        osw.write('\u3042'); // Hiragana osw.flush; }     osw.close; array = bos.toByteArray; if ( array.length != 30001 ) System.out.println(          &quot;OutputStreamWriter bug: number of UTF8 bytes written should be 30001, &quot;           + &quot;not be &quot; + array.length ); }  catch( CharConversionException ex) {     System.out.println(         &quot;OutputStreamWriter bug: CharConversionException should not occur.&quot; ); }