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 130F6D1B562 for ; Fri, 4 Jun 2004 21:19:23 -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 08136-02 for ; Sat, 5 Jun 2004 00:19:22 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 4A00DD1B48C for ; Fri, 4 Jun 2004 21:19:17 -0300 (ADT) Received: from p41-max2.pmr.ihug.co.nz ([203.173.220.105] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1BWOu2-00021v-00; Sat, 05 Jun 2004 12:19:15 +1200 Message-ID: <40C1124B.9010701@opencloud.com> Date: Sat, 05 Jun 2004 12:22:35 +1200 From: Oliver Jowett User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Vasiliev Ivan Cc: pgsql-jdbc@postgresql.org Subject: Re: bug report References: <1701580283984.20040604183311@folksnet.com> In-Reply-To: <1701580283984.20040604183311@folksnet.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200406/18 X-Sequence-Number: 10220 Vasiliev Ivan wrote: > Hello All! > I use a database with type UNICODE, execute query "select * > from some_table". One field has type text. There are some Europe symbols, > which code more than 128. In theory this should be ok assuming the data was inserted with a suitable client_encoding. > In method > private synchronized String Enconding#decodeUTF8(byte data[], int offset, int length) > throws SQLException > exeption ArrayIndexOutOfBoundsException occures in last else block: > } else { // length == 2 (maybe add checking for length > 3, throw exception if it is > y = data[i+1] & 0xFF; > val = (z - 0xC0)* (pow2_6)+(y-0x80); > l_cdata[j++] = (char) val; > i+=2; > } > Then your PSQLException is created. Do you have a sample schema & data that shows this problem so we can reproduce it? Or can you capture the raw byte-by-byte data given to decodeUTF8() that causes the problem? > But I have made a trick : > } catch (Exception l_e) { > try { > return new String(data, offset, length, "UTF-8"); > } catch(Exception e) { > throw new PSQLException("postgresql.con.invalidchar", l_e); > } > } > And, as no exception occures during string creation, your "fast code" > decodeUTF8() has an error, I suppose.... I believe the String constructors *ignore* errors in the incoming data, replacing them with placeholder characters. Just to check, your JDBC application is not changing client_encoding, right? -O