Could not convert UTF-8 to ISO8859-1

Поиск
Список
Период
Сортировка
От Chris Anderson
Тема Could not convert UTF-8 to ISO8859-1
Дата
Msg-id A6846A72-582F-11D8-84A2-000393D3B384@pobox.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: TIME ZONE SQL
Следующее
От: "Richard Sydney-Smith"
Дата:
Сообщение: Re: Slow sub-selects, max and count(*)