Re: JDBC to load UTF8@psql to latin1@mysql

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: JDBC to load UTF8@psql to latin1@mysql
Date: 2012-12-14 14:56:05
Message-ID: 50CB3E05.4060509@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/14/2012 09:49 AM, Adrian Klaver wrote:
> Original Poster
Thanks. And more info:
Mysql
+--------------------------+--------+
| Variable_name | Value |
+--------------------------+--------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
+--------------------------+--------+
SHOW VARIABLES LIKE "character\_set\_database";
+------------------------+--------+
| Variable_name | Value |
+------------------------+--------+
| character_set_database | latin1 |
+------------------------+--------+

Psql everywhere is utf8.

Where could be the problem located?

Also by using the java encoding methods, all characters except "È" are
transformed correctly.

Thanks alot!
Emi
--
public static String utf8_to_latin1(String str)
throws Exception
{
try
{
if(str.indexOf("È")>=0)
{
str = str.replaceAll("È", "E");
}
byte[] convertStringToByte = str.getBytes("UTF-8");
str = new String(convertStringToByte,
"ISO-8859-1");
return str;
}catch(Exception e)
{
log.error("utf8_to_latin1 Error: " + e.getMessage());
log.error(e);
throw e;
}
}

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-12-14 15:15:59 Re: JDBC to load UTF8@psql to latin1@mysql
Previous Message Adrian Klaver 2012-12-14 14:52:03 Re: Problem starting PG-9.2 on non-default port