Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 61370 invoked from network); 19 Apr 2007 03:38:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Apr 2007 03:38:36 -0000 Received: (qmail 66599 invoked by uid 500); 19 Apr 2007 03:38:42 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 66575 invoked by uid 500); 19 Apr 2007 03:38:42 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 66566 invoked by uid 99); 19 Apr 2007 03:38:42 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Apr 2007 20:38:42 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Apr 2007 20:38:35 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7569E71407D for ; Wed, 18 Apr 2007 20:38:15 -0700 (PDT) Message-ID: <11602830.1176953895478.JavaMail.jira@brutus> Date: Wed, 18 Apr 2007 20:38:15 -0700 (PDT) From: "Ruth Cao (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-3702) [classlib][luni] Reader and Writer convert characters incorrectly In-Reply-To: <26141655.1176925035459.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-3702?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489920 ] Ruth Cao commented on HARMONY-3702: ----------------------------------- Hello Vasily, I've tried some test data but cannot reproduce this issue. May you pls upload the "test.dat" file you use so that I can investigate it further? Thanks a lot. > [classlib][luni] Reader and Writer convert characters incorrectly > ----------------------------------------------------------------- > > Key: HARMONY-3702 > URL: https://issues.apache.org/jira/browse/HARMONY-3702 > Project: Harmony > Issue Type: Bug > Components: Classlib > Reporter: Vasily Zakharov > > java.io.Reader converts bytes to characters differently than RI does. Also, java.io.Writer converts characters to bytes differently than RI does. > The attached test.dat file contains random test data and must be placed to the current directory. ReaderTest below reads that file with FileReader and then dumps it to standard output by converting each character to int. WriterTest reads the test.dat file with FileInputStream, converts each byte to character by casting and then dumps the resulting characters to standard output by OutputStreamWriter. > public class ReaderTest { > public static void main(String args[]) throws Exception { > char[] buffer = new char[0x100000]; > java.io.Reader reader = new java.io.FileReader("test.dat"); > int length = reader.read(buffer, 0, buffer.length); > for (int i = 0; i < length; i++) { > System.out.println((int) buffer[i]); > } > } > } > public class WriterTest { > public static void main(String args[]) throws Exception { > byte[] buffer = new byte[0x100000]; > java.io.InputStream iStream = new java.io.FileInputStream("test.dat"); > int length = iStream.read(buffer, 0, buffer.length); > char[] charBuffer = new char[length]; > for (int i = 0; i < length; i++) { > charBuffer[i] = (char) buffer[i]; > } > java.io.Writer writer = new java.io.OutputStreamWriter(System.out); > writer.write(charBuffer, 0, length); > writer.close(); > } > } > In both cases, output files on RI and on Harmony are different: > $ RI/bin/java ReaderTest > reader.ri > $ HY/bin/java ReaderTest > reader.hy > $ diff --binary -q reader.ri reader.hy > Files reader.ri and reader.hy differ > $ RI/bin/java WriterTest > writer.ri > $ HY/bin/java WriterTest > writer.hy > $ diff --binary -q writer.ri writer.hy > Files writer.ri and writer.hy differ > My investigations show that the problem is in Reader/Writer, not in InputStream/OutputStream. Also, I've tried other implementations of Reader/Writer and they share the same problem. > The problem was discovered on Windows XP/IA-32 but probably affects other platforms too. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.