pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Anderson <cva@pobox.com>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Could not convert UTF-8 to ISO8859-1
Date: Thu, 5 Feb 2004 17:04:28 -0600
Message-ID: <A6846A72-582F-11D8-84A2-000393D3B384@pobox.com> (raw)

I've noticed a difference in behavior between 7.2 and 7.3 with regards 
to character recoding and I'm a little perplexed about how to work 
around.

I have a database in LATIN-1 that is accessed read-write by a Java app. 
Naturally, the Java code keeps all of its strings in UTF8 so when I 
prepare a sql statement, someone is recoding these characters to 
LATIN-1 for me.

In 7.2, if the Unicode string contained a character that wasn't valid 
in the database encoding (LATIN-1) either pgsql or the jdbc driver (I'm 
not really sure which) would silently convert these characters to 
question marks.

In 7.3, the same string will throw a "Could not convert UTF-8 to 
ISO8859-1" error.

I can work around this by doing the following hack in Java:

	String s = "some unicode string";
	byte[] tmp = s.getBytes("latin1");
	s = new String(tmp, 0, tmp.length, "latin1");

But I'm sure there is a better way to do this.

Any suggestions?

cva




Message-ID: <A6846A72-582F-11D8-84A2-000393D3B384@pobox.com>
Permalink:  ../A6846A72-582F-11D8-84A2-000393D3B384@pobox.com/
Also on:    postgresql.org/message-id/A6846A72-582F-11D8-84A2-000393D3B384@pobox.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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: cva@pobox.com
  Subject: Re: Could not convert UTF-8 to ISO8859-1
  In-Reply-To: <A6846A72-582F-11D8-84A2-000393D3B384@pobox.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