pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: J. Michael Crawford <jmichael@gwi.net>
Cc: Kris Jurka <books@ejurka.com>
Cc: pgsql-general@postgresql.org
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] Using Postgres with Latin1 (ISO8859-1)
Date: Tue, 09 Nov 2004 10:55:55 +1300
Message-ID: <418FEB6B.3000700@opencloud.com> (raw)
In-Reply-To: <6.1.2.0.2.20041108160948.02fd4638@pop.suscom-maine.net>
References: <418F8A30.8010305@deg.cc>
	<6.1.2.0.2.20041108105839.02fdcfe0@pop.suscom-maine.net>
	<Pine.BSO.4.56.0411081210050.23287@leary.csoft.net>
	<6.1.2.0.2.20041108160948.02fd4638@pop.suscom-maine.net>

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



view thread (3+ messages)  latest in thread

Message-ID: <418FEB6B.3000700@opencloud.com>
Permalink:  ../418FEB6B.3000700@opencloud.com/
Also on:    postgresql.org/message-id/418FEB6B.3000700@opencloud.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: oliver@opencloud.com, jmichael@gwi.net, books@ejurka.com, pgsql-general@postgresql.org
  Subject: Re: [JDBC] Using Postgres with Latin1 (ISO8859-1)
  In-Reply-To: <418FEB6B.3000700@opencloud.com>
  References: <418F8A30.8010305@deg.cc> <6.1.2.0.2.20041108105839.02fdcfe0@pop.suscom-maine.net> <Pine.BSO.4.56.0411081210050.23287@leary.csoft.net> <6.1.2.0.2.20041108160948.02fd4638@pop.suscom-maine.net> <418FEB6B.3000700@opencloud.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