Encoding nightmare! Pls help!

Поиск
Список
Период
Сортировка
От John Sidney-Woollett
Тема Encoding nightmare! Pls help!
Дата
Msg-id 2375.192.168.0.64.1075747482.squirrel@mercury.wardbrook.com
обсуждение исходный текст
Ответы Re: Encoding nightmare! Pls help!
Re: Encoding nightmare! Pls help!
Список pgsql-jdbc
I've had a discussion on the general list about the implications for
storing accented characters within a postgres (7.4.1) db.

As a result, I have created a database with no locale = C locale (using
initdb {other parms} --no-locale)

Here's the database (test) with UNICODE encoding

         List of databases
     Name     |  Owner   | Encoding
--------------+----------+----------
 test         | postgres | UNICODE
 template0    | postgres | UNICODE
 template1    | postgres | UNICODE

The problem I'm having is that I CANNOT write accented characters into the
database or get them out correctly using my java code and the
pg74.1jdbc3.jar file.

Using psql, I select the data (with client encoding = UNICODE), and I get

tést.jpg

With client encoding = LATIN1, I get

tést.jpg

But in my little java test app, I get:

tést.jpg, tést.jpg, tést.jpg,

I want tést.jpg!!!!!

Here is the offending section of code:

String filename = rset.getString(2);
System.out.print(filename);
System.out.print(", ");

if (filename != null)
{
  try
  {
    filename = new String(rset.getBytes(2), "UTF-8");
  }
  catch (UnsupportedEncodingException e)
  {
    System.out.println("Cannot decode string?");
  }

  System.out.print(filename);
  System.out.print(", ");

  try
  {
    filename = new String(rset.getBytes(2), "ISO-8859-1");
  }
  catch (UnsupportedEncodingException e)
  {
    System.out.println("Cannot decode string?");
  }

  System.out.print(filename);
  System.out.print(", ");
}

Can anyone explain what I am doing wrong? I have become so confused by all
this, that I don't think I can see the problem straight anymore.

How can I read and write unicode chars into the db. Is there some magick
parameter that needs to be passed when setting up the connection/driver?

Thanks for any/all help!!

John Sidney-Woollett



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

Предыдущее
От: Anderson dos Santos
Дата:
Сообщение: to leave
Следующее
От: Barry Lind
Дата:
Сообщение: Re: Encoding nightmare! Pls help!