pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: J. Michael Crawford <jmichael@gwi.net>
To: pgsql-jdbc@postgresql.org
Subject: JDBC Latin1 problem
Date: Wed, 04 Aug 2004 14:34:39 -0400
Message-ID: <6.1.1.1.2.20040804140140.0337bf10@mail.nuomo.com> (raw)



   We have a PostgreSQL 7.3.4 database running in redhat, defined as Latin1 
when created, with the client connection sent to Latin1.  The data looks 
fine when queried.  When using our server application running in windows 
(jvm build 1.4.2_04-b05), with the pg73jdbc3.jar jdbc driver, we get the 
right information from the rs.getString() method, and it looks fine in web 
pages encoded with Latin1.

   However, when using the exact same classes and driver on the redhat 
Linux box (jvm build 1.4.2_01-b06), we get garbage wherever there's a latin 
character.  Same database, same classes, same driver.

   The Linux jvm has a default character encoding of UTF8, while the 
windows jvm has a default character encoding of Cp1252.

   Here's what we've tried:


?charSet=

   We've tried every combination of adding ?charSet= to the url, such as 
?charSet=LATIN1, ?charSet=ISO_8859_1, ?charSet=UTF_8, ?charSet=UNICODE, and 
even appending the following to the url: "?charset=" + 
sun.io.ByteToCharConverter.getDefault().getCharacterEncoding();  We've 
tried both dashes and underscores.  We've also tried ?encoding= as well.


data = resultSet.getString("page_title_es");
byte[] text=data.getBytes("utf-8");
String data1=new String(text,"LATIN1");

   We've tried the above going from utf-8 to Latin1, utf-8 to utf-8, utf-8 
to iso-8859-1, iso-8859-1 to utf-8, iso-8859-1 to Latin1, iso-8859-1 to 
iso-8859-1, Latin1 to Latin1, Latin1 to utf-8, Latin1 to iso-8859-1.  We 
may have tried others.  Nothing has helped.  We'll try nine at a time and 
all will come up with some variation of "Introducción"  instead of 
"Introducción" (hopefully this message shows the second introduccion with 
an accent over the o, and not gibberish).


   Any ideas?  There's probably something very simple that will look 
obvious in hindsight -- I'm sure that others have retrieved Latin1 
characters from a Latin1 database via jdbc on a Linux jvm with a default 
character set of utf-8.  I'm just not sure we'll be able to figure this one 
out on our own.


	- Mike









view thread (3+ messages)  latest in thread

Message-ID: <6.1.1.1.2.20040804140140.0337bf10@mail.nuomo.com>
Permalink:  ../6.1.1.1.2.20040804140140.0337bf10@mail.nuomo.com/
Also on:    postgresql.org/message-id/6.1.1.1.2.20040804140140.0337bf10@mail.nuomo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: jmichael@gwi.net
  Subject: Re: JDBC Latin1 problem
  In-Reply-To: <6.1.1.1.2.20040804140140.0337bf10@mail.nuomo.com>
  References: <6.1.1.1.2.20040804140140.0337bf10@mail.nuomo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox