Could not convert UTF-8 to ISO8859-1 - Mailing list pgsql-sql

From Chris Anderson
Subject Could not convert UTF-8 to ISO8859-1
Date
Msg-id A6846A72-582F-11D8-84A2-000393D3B384@pobox.com
Whole thread Raw
List pgsql-sql
I've noticed a difference in behavior between 7.2 and 7.3 with regards 
to character recoding and I'm a little perplexed about how to work 
around.

I have a database in LATIN-1 that is accessed read-write by a Java app. 
Naturally, the Java code keeps all of its strings in UTF8 so when I 
prepare a sql statement, someone is recoding these characters to 
LATIN-1 for me.

In 7.2, if the Unicode string contained a character that wasn't valid 
in the database encoding (LATIN-1) either pgsql or the jdbc driver (I'm 
not really sure which) would silently convert these characters to 
question marks.

In 7.3, the same string will throw a "Could not convert UTF-8 to 
ISO8859-1" error.

I can work around this by doing the following hack in Java:
String s = "some unicode string";byte[] tmp = s.getBytes("latin1");s = new String(tmp, 0, tmp.length, "latin1");

But I'm sure there is a better way to do this.

Any suggestions?

cva



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: TIME ZONE SQL
Next
From: "Richard Sydney-Smith"
Date:
Subject: Re: Slow sub-selects, max and count(*)