X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9D87DD95C5 for ; Tue, 4 Oct 2005 18:12:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85890-02 for ; Tue, 4 Oct 2005 21:12:54 +0000 (GMT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by svr1.postgresql.org (Postfix) with ESMTP id 74E4DDA0BF for ; Tue, 4 Oct 2005 18:12:52 -0300 (ADT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j94LCsLj025174 for ; Tue, 4 Oct 2005 17:12:54 -0400 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j94LCrV26223 for ; Tue, 4 Oct 2005 17:12:53 -0400 Received: from vpn83-173.boston.redhat.com (vpn83-173.boston.redhat.com [172.16.83.173]) by mail.boston.redhat.com (8.12.8/8.12.8) with ESMTP id j94LCrSr028567 for ; Tue, 4 Oct 2005 17:12:53 -0400 From: Vadim Nasardinov Organization: Red Hat (Westford) To: pgsql-jdbc@postgresql.org Subject: Re: Selecting on non ASCII varchars Date: Tue, 4 Oct 2005 17:14:01 -0400 User-Agent: KMail/1.8.2 References: <19B7E72C-CA44-42AE-803E-E87421EC30F9@broadrelay.com> <43408C35.6020902@opencloud.com> <366C3C4C-7E0A-4154-A02E-8A0B6F016157@broadrelay.com> In-Reply-To: <366C3C4C-7E0A-4154-A02E-8A0B6F016157@broadrelay.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200510041714.01768.vadimn@redhat.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.017 required=5 tests=[AWL=0.017] X-Spam-Level: X-Archive-Number: 200510/17 X-Sequence-Number: 13948 On Tuesday 04 October 2005 16:16, Jeremy LaCivita wrote: > Hmmm >=20 > so it turns out if i take all my Strings and do this: >=20 > str =3D new String(str.getBytes(), "utf-8"); >=20 > then it works. >=20 > Correct me if i'm wrong, but that says to me that the Strings were > in UTF-8 already, but Java didn't know it, so it couldn't send them > to postgres properly. It's meaningless to ask what encoding a String has. String are sequence of chars -- they don't have an encoding. The notion of "encoding" comes into play only when you have to represent a String as a sequence of bytes. So, if this returns true for you: str.equals(new String(str.getBytes(), "utf-8")); that means your default encoding is either utf-8 or a subset of utf-8, at least for the characters found in str. String#getBytes() uses the default encoding which may be specified via the environment variable LANG on on Unix-like systems. So, if my default encoding is UTF-8, I get this: | $ echo $LANG | en_US.UTF-8 | $ bsh2 | BeanShell 2.0-0.b1.7jpp - by Pat Niemeyer (pat@pat.net) | bsh % print(System.getProperty("file.encoding")); | UTF-8 | bsh % str =3D "Funny char: \u00e8"; | bsh % print(str); | Funny char: =C3=A8 | bsh % print(str.equals(new String(str.getBytes(), "utf-8"))); | true | bsh % If I change the default encoding to ISO-8859-1, I get this: | $ env LANG=3Den_US.iso88591 bsh2 | BeanShell 2.0-0.b1.7jpp - by Pat Niemeyer (pat@pat.net) | bsh % print(System.getProperty("file.encoding")); | ISO-8859-1 | bsh % str =3D "Funny char: \u00e8"; | bsh % print(str); | Funny char: =C3=A8 | bsh % print(str.equals(new String(str.getBytes(), "utf-8"))); | false | bsh %