Обсуждение: failing using unicode

Поиск
Список
Период
Сортировка

failing using unicode

От
per.sil@gmx.it
Дата:
Hi folks,

does anybody know a solution for my probem?

I am using PostgreSQL 7.2.1 compiled with multibyte support on Gentoo-Linux
1.2
# psql -V
   psql (PostgreSQL) 7.2.1
   contains support for: readline, history, multibyte

my java servlet application is running on sun's JDK 1.4 and I tried the
latest JDBC driver pg73jdbc3.jar and the former one pg72jdbc2.jar.

The database has been created with:
# createdb -E UNICODE test_db

Writing a java String to the database, something like the name:
"Traunmüller" gives me to the unicode string "Traunm\303\274ller" in psql, which seems
correct, does it?
The java statment used by the underlaying O/R tool is (pseudo-code):
   preparedStatement.setObject(index, "Traunmüller", sqlType);

The SQL type of the column is LONGVARCHAR in JDBC, and bytea in the
database.

BUT then fetching the same string from the database in the same program,
some line below, using the same driver does not convert the unicode character
back to "ü". System.out.println writes:
    Traunm\303\274ller
instead of
    Traunmüller

why this?

I tried to switch to LATIN1 encoding and adding the query data
"?charSet=LATIN1" to the database URL, without success. Did I miss anything in the
documentation?

Any help is welcome.

Greetings,
   Perolo


--
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!


Re: failing using unicode

От
Barry Lind
Дата:
You are leaving out an important part of your code.  How are you getting
the value back and how are you printing it?

Also why are you using the bytea datatype?  That is for binary data, you
should be using the text datatype.

thanks,
--Barry



per.sil@gmx.it wrote:
> Hi folks,
>
> does anybody know a solution for my probem?
>
> I am using PostgreSQL 7.2.1 compiled with multibyte support on Gentoo-Linux
> 1.2
> # psql -V
>    psql (PostgreSQL) 7.2.1
>    contains support for: readline, history, multibyte
>
> my java servlet application is running on sun's JDK 1.4 and I tried the
> latest JDBC driver pg73jdbc3.jar and the former one pg72jdbc2.jar.
>
> The database has been created with:
> # createdb -E UNICODE test_db
>
> Writing a java String to the database, something like the name:
> "Traunmüller" gives me to the unicode string "Traunm\303\274ller" in psql, which seems
> correct, does it?
> The java statment used by the underlaying O/R tool is (pseudo-code):
>    preparedStatement.setObject(index, "Traunmüller", sqlType);
>
> The SQL type of the column is LONGVARCHAR in JDBC, and bytea in the
> database.
>
> BUT then fetching the same string from the database in the same program,
> some line below, using the same driver does not convert the unicode character
> back to "ü". System.out.println writes:
>     Traunm\303\274ller
> instead of
>     Traunmüller
>
> why this?
>
> I tried to switch to LATIN1 encoding and adding the query data
> "?charSet=LATIN1" to the database URL, without success. Did I miss anything in the
> documentation?
>
> Any help is welcome.
>
> Greetings,
>    Perolo
>
>