ArrayIndexOutOfBoundsException in Encoding.decodeUTF8()

From: Joseph Shraibman <jks(at)selectacast(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: ArrayIndexOutOfBoundsException in Encoding.decodeUTF8()
Date: 2003-01-07 23:20:25
Message-ID: 3E1B60B9.5020900@selectacast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

java.lang.ArrayIndexOutOfBoundsException: 3
at org.postgresql.core.Encoding.decodeUTF8(Encoding.java:253)
at org.postgresql.core.Encoding.decode(Encoding.java:165)
at org.postgresql.core.Encoding.decode(Encoding.java:181)
at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getString(AbstractJdbc1ResultSet.java:97)

The relavent code is:

while (i < k) {
z = data[i] & 0xFF;
if (z < 0x80) {
l_cdata[j++] = (char)data[i];
i++;
} else if (z >= 0xE0) { // length == 3
y = data[i+1] & 0xFF; //<<== THIS IS LINE 253
x = data[i+2] & 0xFF;
val = (z-0xE0)*pow2_12 + (y-0x80)*pow2_6 + (x-0x80);
l_cdata[j++] = (char) val;
i+= 3;
} else { // length == 2 (maybe add checking for length > 3, throw exception if it is

And in the method that calls that:

if (encoding.equals("UTF-8")) {
return decodeUTF8(encodedString, offset, length);
}

The thing is my database encoding is SQL_ASCII

=> SELECT version(), getdatabaseencoding() ;
version
| getdatabaseencoding
---------------------------------------------------------------------------------------------------------+---------------------
PostgreSQL 7.3.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2 20020903 (Red Hat
Linux 8.0 3.2-7) | SQL_ASCII
(1 row)

... so why is it trying to decode the string as UTF-8? I just upgraded this database from
7.2.3 yesterday.

--
Joseph Shraibman
joseph(at)xtenit(dot)com
Increase signal to noise ratio. http://xis.xtenit.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joseph Shraibman 2003-01-07 23:32:14 Re: ArrayIndexOutOfBoundsException in Encoding.decodeUTF8()
Previous Message scott.marlowe 2003-01-07 23:16:09 Re: [PERFORM] PostgreSQL and memory usage

Browse pgsql-jdbc by date

  From Date Subject
Next Message Joseph Shraibman 2003-01-07 23:32:14 Re: ArrayIndexOutOfBoundsException in Encoding.decodeUTF8()
Previous Message Kris Jurka 2003-01-07 22:00:38 Re: JDBC Driver -- getImportedKeys