You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Tony Wu (JIRA)" <ji...@apache.org> on 2007/07/10 08:38:05 UTC
[jira] Assigned: (HARMONY-4400) [classlib][luni]
InputStreamReader/OutputStreamWriter expecting problems in
decoding/encoding some bytes/chars using MS932 encoding
[ https://issues.apache.org/jira/browse/HARMONY-4400?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tony Wu reassigned HARMONY-4400:
--------------------------------
Assignee: Tony Wu
> [classlib][luni] InputStreamReader/OutputStreamWriter expecting problems in decoding/encoding some bytes/chars using MS932 encoding
> -----------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-4400
> URL: https://issues.apache.org/jira/browse/HARMONY-4400
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Elena Sayapina
> Assignee: Tony Wu
> Priority: Minor
>
> InputStreamReader/OutputStreamWriter expecting problems in decoding/encoding some bytes/chars using MS932 (windows-31j) encoding.
> Please, consider the two following tests:
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStreamReader;
> import java.io.OutputStreamWriter;
> public class jEncodingTest {
> public static void main(String[] args) throws IOException {
> boolean passed = true;
> byte[] data = {-121,84, -121,85, -121,86, -121,87, -121,88, -121,89,
> -121,90, -121,91, -121,92, -121,93, -121,-118, -121,-124,
> -127,-25, -127,-26, -127,-29, -127,-32, -127,-33, -127,-37,
> -127,-38, -127,-65, -127,-66};
> ByteArrayInputStream input = new ByteArrayInputStream(data);
> ByteArrayOutputStream output = new ByteArrayOutputStream(data.length);
> InputStreamReader reader = new InputStreamReader(input, "MS932");
> OutputStreamWriter writer = new OutputStreamWriter(output, "MS932");
> for(int i=0; i<data.length; i++) writer.write(reader.read());
> reader.close();
> writer.close();
> ByteArrayInputStream patternStream = new ByteArrayInputStream(data);
> ByteArrayInputStream stream = new ByteArrayInputStream(output.toByteArray());
> for(int i=0; i<data.length; i++) {
> int pattern = patternStream.read();
> int produced = stream.read();
> if (pattern != produced) {
> passed = false;
> System.out.println(i + ": " + " Expected " + (Integer.toHexString(pattern).toUpperCase()) +
> " Found " + (Integer.toHexString(produced).toUpperCase()));
> }
> }
> if (passed) System.out.println("TEST PASSED");
> else System.out.println("TEST FAILED");
> }
> }
> import java.io.ByteArrayInputStream;
> import java.io.IOException;
> import java.io.InputStreamReader;
> public class jEncodingTest2 {
> public static void main(String[] args) throws IOException {
> byte[] data = new byte[] {127};
> ByteArrayInputStream stream = new ByteArrayInputStream(data);
> InputStreamReader reader = new InputStreamReader(stream, "MS932");
> int produced = reader.read();
> reader.close();
> if (produced == data[0]) System.out.println("TEST PASSED");
> else System.out.println("TEST FAILED: " +
> "Expected " + Integer.toHexString(data[0]).toUpperCase() +
> " Found " + Integer.toHexString(produced).toUpperCase());
> }
> }
> Output on Harmony-r552422-msvc-release:
> jEncodingTest:
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
> as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r552422, (Jul 2 2007), Windows/ia32/msvc 1310, release build
> http://harmony.apache.org
> 0: Expected 87 Found FA
> 1: Expected 54 Found 4A
> 2: Expected 87 Found FA
> 3: Expected 55 Found 4B
> 4: Expected 87 Found FA
> 5: Expected 56 Found 4C
> 6: Expected 87 Found FA
> 7: Expected 57 Found 4D
> 8: Expected 87 Found FA
> 9: Expected 58 Found 4E
> 10: Expected 87 Found FA
> 11: Expected 59 Found 4F
> 12: Expected 87 Found FA
> 13: Expected 5A Found 50
> 14: Expected 87 Found FA
> 15: Expected 5B Found 51
> 16: Expected 87 Found FA
> 17: Expected 5C Found 52
> 18: Expected 87 Found FA
> 19: Expected 5D Found 53
> 20: Expected 87 Found FA
> 21: Expected 8A Found 58
> 22: Expected 87 Found FA
> 23: Expected 84 Found 5A
> 24: Expected 81 Found 87
> 25: Expected E7 Found 92
> 26: Expected 81 Found FA
> 27: Expected E6 Found 5B
> 28: Expected 81 Found 87
> 29: Expected E3 Found 95
> 30: Expected 81 Found 87
> 31: Expected E0 Found 90
> 32: Expected 81 Found 87
> 33: Expected DF Found 91
> 34: Expected 81 Found 87
> 35: Expected DB Found 96
> 36: Expected 81 Found 87
> 37: Expected DA Found 97
> 38: Expected 81 Found 87
> 39: Expected BF Found 9B
> 40: Expected 81 Found 87
> 41: Expected BE Found 9C
> TEST FAILED
> jEncodingTest2:
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
> as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r552422, (Jul 2 2007), Windows/ia32/msvc 1310, release build
> http://harmony.apache.org
> TEST FAILED: Expected 7F Found 1A
> Output on RI:
> jEncodingTest:
> java version "1.5.0_11"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
> TEST PASSED
> jEncodingTest2:
> java version "1.5.0_11"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
> TEST PASSED
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.