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

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: JDBC to load UTF8@psql to latin1@mysql
Date: 2012-12-12 18:19:42
Message-ID: 50C8CABE.5060203@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> Is there a simple way to load UTF8 data in psql to mysql(with latin1
> encoding) through JDBC?
>
JAVA codes work for most of characters, but not "-È". Someone knows why
the following codes cannot load "-È" to mysql(at)latin1?

Thanks a lot!

--
public static String utf8_to_latin1(String str)
throws Exception
{
try
{
String stringToConvert = str;
byte[] convertStringToByte = stringToConvert.getBytes("UTF-8");
return new String(convertStringToByte, "ISO-8859-1");
}catch(Exception e)
{
log.error("utf8_to_latin1 Error: " + e.getMessage());
log.error(e);
throw e;
}
}

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sergey Konoplev 2012-12-12 18:24:42 Re: NOTIFY/LISTEN on server, asynchronous processing
Previous Message Mihai Popa 2012-12-12 18:18:57 Re: large database