Обсуждение: bug report
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 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. 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.... Database server version: PostgreSQL 7.4.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.2 20030222 (ASPLinux 3.2.2-5asp) JDBC driver: pg74.213.jdbc3.jar (this method doesn't differ from driver devpgjdbc3.jar) Let me know, if I wrong, or may be you want some additional information. -- Best regards, Vasiliev mailto:biggod@folksnet.com
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
hi all,
i want unsubscribe these mailing-list for this mail...but i can't.
can you help me, how should i do, because i 've tried 10x to send mail to majordomo@postgresql.org, but it doesn't work.
i ' m very thankful for your help,
best regards,
edwin karundeng
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger