X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 29DD353F6B for ; Wed, 27 Apr 2005 10:13:40 -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 48678-08 for ; Wed, 27 Apr 2005 13:13:37 +0000 (GMT) Received: from mnc.ch (www.mnc.ch [212.23.250.43]) by svr1.postgresql.org (Postfix) with ESMTP id 7C48853A26 for ; Wed, 27 Apr 2005 10:13:35 -0300 (ADT) Received: (qmail 9369 invoked from network); 27 Apr 2005 15:13:39 +0200 Received: from 62-2-77-204.business.cablecom.ch (HELO meuh.mnc.ch) (62.2.77.204) by www.mnc.ch with SMTP; 27 Apr 2005 15:13:39 +0200 Received: by meuh.mnc.ch (Postfix, from userid 1000) id 6537F23F713; Wed, 27 Apr 2005 15:13:35 +0200 (CEST) To: Anders Hermansen Cc: pgsql-jdbc@postgresql.org Subject: Re: ERROR: could not convert UTF-8 character 0x00ef to ISO8859-1 possiblesolution References: <426E685F.1020600@ingenian.com> <87d5sgecyi.fsf@meuh.mnc.ch> <20050427104944.GB25361@online.no> <87y8b4cv7j.fsf@meuh.mnc.ch> <20050427115434.GB30285@online.no> From: Guillaume Cottenceau Date: 27 Apr 2005 15:13:35 +0200 In-Reply-To: <20050427115434.GB30285@online.no> Message-ID: <873btccqgw.fsf@meuh.mnc.ch> Lines: 65 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.052 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200504/176 X-Sequence-Number: 12783 Anders Hermansen writes: > * Guillaume Cottenceau (gc@mnc.ch) wrote: > > Anders Hermansen writes: > > > * Guillaume Cottenceau (gc@mnc.ch) wrote: > > > > Isn't there a problem with your UTF-8 data containing 0x00EF? > > > > > > E0 to EF hex (224 to 239): first byte of a three-byte sequence. > > > > Well 00 is first byte here, isn't it? > > UTF-8 is a byte sequence, so it's not about the first byte in the whole > sequence. But about the first byte in a tree byte sequece. Yes. I forgot that you assumed the machine was big-endian. So the UTF-8 character is here probably first byte 0xEF, second byte 0x00? I did my test with first byte 0x00 and second byte 0xEF, hence confusion with your initial comment. My reasoning was that if the first byte of this two-byte sequence is 0x00 then the rule that 0xEF is first byte of a three-byte sequence doesn't apply, since 0xEF is second byte in the sequence. > There should be no nul (0) bytes when encoding UTF-8. I believe > this is in the specification to allow it to be compatible with > C nul-terminated strings. > > I believe that the byte sequence 0x00EF i illegal UTF-8 because: > 1) It contains nul (0x00) byte > 2) 0xEF is not followed by two more bytes > > On the other hand U+00EF is a valid unicode code point. Which points to: I think this is assumed little-endian, e.g. first byte 0x00 and second byte 0xEF (especially because UTF-8 is just a series of bytes without any endianness aspects, so it makes good sense to actually read this left-to-right, e.g. byte 0x00 first). > LATIN SMALL LETTER I WITH DIAERESIS > It is encoded as 0xC3AF in UTF-8 > As 0x00EF in UTF-16 (and UCS-2 ?) Yes to "and UCS-2". Two-byte sequences in UCS-2 and UTF-16 are the same[1]. > As 0xEF in ISO-8859-1 Hum I think I may understand what's going on here. It's possible that in the message: ERROR: could not convert UTF-8 character 0x00ef to ISO8859-1 when they say "0x00ef" they don't talk about UTF-8 per-see but they use the unicode representation (which is error prone). Ref: [1] UCS-2 is a subset of UTF-16 which comprises all the 2-byte sequence characters but no 3 or 4-byte sequence characters -- Guillaume Cottenceau