Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 93467 invoked from network); 3 May 2009 15:29:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 May 2009 15:29:46 -0000 Received: (qmail 99648 invoked by uid 500); 3 May 2009 15:29:45 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 99576 invoked by uid 500); 3 May 2009 15:29:45 -0000 Mailing-List: contact dev-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 dev@harmony.apache.org Received: (qmail 99565 invoked by uid 99); 3 May 2009 15:29:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 May 2009 15:29:45 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of oliver.deakin@googlemail.com designates 209.85.219.161 as permitted sender) Received: from [209.85.219.161] (HELO mail-ew0-f161.google.com) (209.85.219.161) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 May 2009 15:29:35 +0000 Received: by ewy5 with SMTP id 5so3218975ewy.36 for ; Sun, 03 May 2009 08:29:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=nrHhayKBY/6rMW3dh+VFL7xMc78byX1GdxvC34KD8aI=; b=OR5WrlI8PKUsUwwhyIH/z6gqjz9qFgQmIjSjxSuHfofcLrE/NvoXbds3YWRmC+VVB2 ThJ2vZqzOuHL2NfDg0E5Cng9iX3DG7iKDJZrYKCdVX1Bacw9xgKHp4mI6HrQlDyNtzHQ 9m/iCjFzea0znK31CO24Cwi/XUN6Il4Y+vQhk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=SIivU1RY8Azm9CCE1thhQ7Ij6b3YYs7pmX4Q2zXUJJW1rU3l5JMNZY7JvAaKZvCqIb zWulY/c+5CpODNfI/8CCTyvjti+ZpPiT2qWzUWxqRLrSMN8oY+VfNLJKP20n8zUQIpiP 87dNP7NgXnOIAlbfarP1K2H67EPZBd14ceWgE= Received: by 10.210.92.8 with SMTP id p8mr5060574ebb.23.1241364554159; Sun, 03 May 2009 08:29:14 -0700 (PDT) Received: from ?192.168.1.4? ([87.115.65.112]) by mx.google.com with ESMTPS id 10sm9218872eyd.22.2009.05.03.08.29.12 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 03 May 2009 08:29:13 -0700 (PDT) Message-ID: <49FDB848.4050002@googlemail.com> Date: Sun, 03 May 2009 16:29:12 +0100 From: Oliver Deakin User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: dev@harmony.apache.org Subject: Re: svn commit: r770302 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java References: <20090430155430.12BDD238899B@eris.apache.org> <3b3f27c60904300941w3f82ea56lc65a2e55778f8f64@mail.gmail.com> <49FAB3CB.7060804@googlemail.com> <3b3f27c60905021432y7f06668axd719ccb0fb8a931c@mail.gmail.com> In-Reply-To: <3b3f27c60905021432y7f06668axd719ccb0fb8a931c@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Ah right - yes maybe the comment should have read "_into_ UTF-8". I had the assertTrue() just below my change in mind when I wrote it: assertTrue("read returned incorrect char", c == fileString.charAt(0)); I believe the fileString.charAt(0) will return a UTF-8 encoded character here, and the InputStreamReader is also doing a conversion from the platform default encoding into UTF-8, then the assert is carrying out a straight value comparison between the two characters. It was the conversion from the platform default encoding that I was referring to. Hope that's made it clearer. Regards, Oliver Nathan Beyer wrote: > I'm still missing it - what does this have to do with UTF-8? > > fileString.getBytes() will return a byte[] encoded using the platform default > > new InputStreamReader(new FileInputStream(fileName)) will open a file > and read the bytes using the platform default > > I see that there's now symmetry, but it's not about UTF-8. On Windows, > all of this is happening with Windows-1252. > > I'm just confused about the comment - I don't disagree with the code change. > > -Nathan > > On Fri, May 1, 2009 at 3:33 AM, Oliver Deakin > wrote: > >> In the Setup() method we write to the stream using >> >> fos.write(fileString.getBytes()); >> >> but getBytes() converts the string into the native encoding for the >> platform, so when we read the data back in we want to convert it back from >> the native encoding before we try to do any comparison with UTF-8 chars. >> >> Regards, >> Oliver >> >> Nathan Beyer wrote: >> >>> I'm curious about this change. There's no declaration of UTF-8 as the >>> encoding, how is that getting set? AIUI the InputStreamReader will use >>> the default encoding of the operating system. >>> >>> -Nathan >>> >>> On Thu, Apr 30, 2009 at 10:54 AM, wrote: >>> >>> >>>> Author: odeakin >>>> Date: Thu Apr 30 15:54:29 2009 >>>> New Revision: 770302 >>>> >>>> URL: http://svn.apache.org/viewvc?rev=770302&view=rev >>>> Log: >>>> Minor change to ensure we read test data back in UTF-8. >>>> >>>> Modified: >>>> >>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java >>>> >>>> Modified: >>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java >>>> URL: >>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java?rev=770302&r1=770301&r2=770302&view=diff >>>> >>>> ============================================================================== >>>> --- >>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java >>>> (original) >>>> +++ >>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java >>>> Thu Apr 30 15:54:29 2009 >>>> @@ -19,6 +19,7 @@ >>>> >>>> import java.io.File; >>>> import java.io.FileInputStream; >>>> +import java.io.InputStreamReader; >>>> import java.io.FileOutputStream; >>>> import java.io.FilePermission; >>>> import java.io.IOException; >>>> @@ -109,9 +110,9 @@ >>>> * @tests java.io.FileInputStream#read() >>>> */ >>>> public void test_read() throws IOException { >>>> - is = new FileInputStream(fileName); >>>> - int c = is.read(); >>>> - is.close(); >>>> + InputStreamReader isr = new InputStreamReader(new >>>> FileInputStream(fileName)); >>>> + int c = isr.read(); >>>> + isr.close(); >>>> assertTrue("read returned incorrect char", c == >>>> fileString.charAt(0)); >>>> } >>>> >>>> >>>> >>>> >>>> >>>> >>> >> -- >> Oliver Deakin >> Unless stated otherwise above: >> IBM United Kingdom Limited - Registered in England and Wales with number >> 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire >> PO6 3AU >> >> >> > > -- Oliver Deakin Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU