harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Ellison (JIRA)" <j...@apache.org>
Subject [jira] Closed: (HARMONY-2439) [classlib][luni] java.io.OutputStreamWriter.write(int) writes bytes in UTF-8 incorrectly
Date Tue, 24 Apr 2007 15:45:16 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-2439?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Tim Ellison closed HARMONY-2439.
--------------------------------


No response, assuming ok.


> [classlib][luni] java.io.OutputStreamWriter.write(int) writes bytes in UTF-8 incorrectly
> ----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2439
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2439
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Anton Ivanov
>         Assigned To: Tim Ellison
>
> java.io.OutputStreamWriter works wrong when calling to its write(int) method if encoding
specified is UTF-8.
> Following test fails:
> import java.io.*;
> public class TestOutputStreamWriterUTF8 {
>   public static void main(String argv[]) throws Exception {
>       ByteArrayOutputStream out;
>       OutputStreamWriter writer = null;
>       InputStreamReader isr = null;
>       try {
>           out = new ByteArrayOutputStream();
>           writer = new OutputStreamWriter(out, "UTF-8");
>           int upper = 9000;
>           for (int c = 0; c < upper; ++c) {
>               writer.write(c);
>           }
>           writer.flush();
>           byte[] result = out.toByteArray();
>           isr = new InputStreamReader(new ByteArrayInputStream(result),"UTF-8");
>           int expected = 0;
>           for (; expected < upper; ++expected) {
>               if (expected != isr.read()) {
>                   System.out.println("test FAILED:" + expected +" "+ isr.read());
>                   break;
>               }
>           }
>       
>           if (expected == upper) {
>               System.out.println("test PASSED");
>           }
>           isr.close();
>           writer.close();
>        } catch (Exception e) {
>           e.printStackTrace();
>        }
>  }
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message