Re: PostgreSQL JDBC Driver versus Encoding

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: PostgreSQL JDBC Driver versus Encoding
Дата
Msg-id 471949F9.8020304@opencloud.com
обсуждение исходный текст
Ответ на PostgreSQL JDBC Driver versus Encoding  (João Paulo Pires <Joao.Pires@iscte.pt>)
Список pgsql-jdbc
João Paulo Pires wrote:

> I have a PostgreSQL database which encoding is SQL_ASCII.

This is the cause of your problem. SQL_ASCII provides essentially no
encoding information at all, so the JDBC driver does not know how to
translate between the database and Java's internal UTF-16
representation. If you are going to be inserting anything other than
7-bit-ASCII text into it, you are going to have problems.

If you can, try using a database encoding that can represent the data
you are inserting. UTF8 / UNICODE is probably a good choice unless you
have special requirements. See
http://www.postgresql.org/docs/8.2/static/multibyte.html especially the
bit that says:

> The SQL_ASCII setting behaves considerably differently from the other settings. When the server character set is
SQL_ASCII,the server interprets byte values 0-127 according to the ASCII standard, while byte values 128-255 are taken
asuninterpreted characters. No encoding conversion will be done when the setting is SQL_ASCII. Thus, this setting is
notso much a declaration that a specific encoding is in use, as a declaration of ignorance about the encoding. In most
cases,if you are working with any non-ASCII data, it is unwise to use the SQL_ASCII setting, because PostgreSQL will be
unableto help you by converting or validating non-ASCII characters. 

-O

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

Предыдущее
От: João Paulo Pires
Дата:
Сообщение: PostgreSQL JDBC Driver versus Encoding
Следующее
От: John R Pierce
Дата:
Сообщение: Re: PostgreSQL JDBC Driver versus Encoding