Re: [JDBC] Using Postgres with Latin1 (ISO8859-1)

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: [JDBC] Using Postgres with Latin1 (ISO8859-1)
Дата
Msg-id 418FEB6B.3000700@opencloud.com
обсуждение исходный текст
Ответ на Re: [JDBC] Using Postgres with Latin1 (ISO8859-1)  ("J. Michael Crawford" <jmichael@gwi.net>)
Ответы Re: [JDBC] Using Postgres with Latin1 (ISO8859-1)  ("J. Michael Crawford" <jmichael@gwi.net>)
Список pgsql-general
J. Michael Crawford wrote:

> Encoding translations that didn't work:
>
> a) Getting encoded bytes from the result set.  We tried the following
> block five times, once for each different encoding we were trying to
> test with the database:

> b)  Getting a string, turning it bytes, and then translating.  Same
> process as above, but we use result.getString...

>   No matter  what, strings showed up as gibberish in one JVM or another,
> depending upon the native encoding of the database.  A Latin1 database
> worked in the windows JVM, a Unicode in the Linux JVM, but not the other
> way around.

The "right way" is to just use getString() and not do any translation
yourself. The driver has already done the transcoding from whatever the
DB encoding is, to the internal UTF-16 string representation. You don't
need to mess with byte-based representations.

When you then display that string, you will need to use an appropriate
encoding, obviously..

Can you provide a self-contained testcase that demonstrates getString()
doing the wrong thing?

-O

В списке pgsql-general по дате отправления:

Предыдущее
От: Mike Cox
Дата:
Сообщение: Re: Postresql RFD version 2.0 Help Wanted.
Следующее
От: Andrew - Supernews
Дата:
Сообщение: Re: RFD: comp.databases.postgresql.general