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 B098B5346F for ; Wed, 27 Apr 2005 11:05:49 -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 63866-04 for ; Wed, 27 Apr 2005 14:05:38 +0000 (GMT) Received: from mail47.e.nsc.no (mail47.e.nsc.no [193.213.115.47]) by svr1.postgresql.org (Postfix) with ESMTP id 71A43539A1 for ; Wed, 27 Apr 2005 11:05:34 -0300 (ADT) Received: from seymour.intern.yoyo.no (ti122110a080-16343.bb.online.no [83.109.63.215]) by mail47.nsc.no (8.12.11/8.12.11) with ESMTP id j3RE5Zja015754; Wed, 27 Apr 2005 16:05:35 +0200 (CEST) Received: from anders by seymour.intern.yoyo.no with local (Exim 3.36 #1 (Debian)) id 1DQnAU-0000HU-00; Wed, 27 Apr 2005 16:05:34 +0200 Date: Wed, 27 Apr 2005 16:05:34 +0200 From: Anders Hermansen To: Guillaume Cottenceau Cc: pgsql-jdbc@postgresql.org Subject: Re: ERROR: could not convert UTF-8 character 0x00ef to ISO8859-1 possiblesolution Message-ID: <20050427140534.GC582@online.no> Mail-Followup-To: Guillaume Cottenceau , pgsql-jdbc@postgresql.org References: <426E685F.1020600@ingenian.com> <87d5sgecyi.fsf@meuh.mnc.ch> <20050427104944.GB25361@online.no> <87y8b4cv7j.fsf@meuh.mnc.ch> <20050427115434.GB30285@online.no> <873btccqgw.fsf@meuh.mnc.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <873btccqgw.fsf@meuh.mnc.ch> X-Editor: Vim http://www.vim.org/ X-Operating-System: Linux/2.6.11.7 (i686) User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200504/179 X-Sequence-Number: 12786 * Guillaume Cottenceau (gc@mnc.ch) wrote: > Anders Hermansen writes: > > 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. Endianness is not a problem when working with a sequnce of bytes (8-bit) like in utf-8. It only becomes a problem when you deal with more than 1 byte representing 1 value. So it's an issue in UTF-16 which is big-endian by default I think. So I interpreted the message "ERROR: could not convert UTF-8 character 0x00ef to ISO8859-1" as a byte sequence with 0x00 first, and then 0xef. Maybe that's a wrong assumption. > > 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). As I said above. Endiness is not an issue for UTF-8. The byte _sequence_ is always read from start to end. > > 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]. Yes. > > 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). If 0x00ef refers to a unicode codepoint, it should not have been a problem to convert it to ISO-8859-1 (0xef). If 0x00ef refers to a byte sequence, then the error message is a bit misleading because it's not a character but a byte sequence. And the error is decoding the UTF-8, not encoding the ISO-8859-1. Anders Hermansen