9 messages in com.mysql.lists.javaRE: Encoding independent text data in...
FromSent OnAttachments
Richard Bolen01 May 2003 11:11 
Lastric Igor05 May 2003 01:16 
GV05 Jul 2003 16:17 
Frank Gates05 Jul 2003 16:32 
Frank Gates05 Jul 2003 16:38 
GV06 Jul 2003 03:09 
mike markovich07 Jul 2003 07:55 
Frank Gates07 Jul 2003 08:03 
Guus Holshuijsen07 Jul 2003 23:13 
Subject:RE: Encoding independent text data in mysql?
From:Lastric Igor (last@galexis.com)
Date:05/05/2003 01:16:58 AM
List:com.mysql.lists.java

Hi ,

Why should you want to store different encodings into mySql DB?

You can easily do conversion after you retrieve it from the DB.

Try this: public static String encode(String value) { String toReturn = null; if (value != null && value.length() > 0) { try { toReturn = new String(value.getBytes("ISO-8859-1"), PropertiesManager.getEncoding()); } catch (UnsupportedEncodingException e) { } } return toReturn; }

public static String decode(String value) { String toReturn = null; if (value != null && value.length() > 0) { try { toReturn = new String(value.getBytes(PropertiesManager.getEncoding()), "ISO-8859-1"); } catch (UnsupportedEncodingException e) { } } return toReturn; }

- PropertiesManager.getEncoding() - gives the encoding configured for the application - instead of hardcoding "ISO-8859-1", one could ask for SystemSetting file.encoding used by JVM

Is there a way to store text data in various encodings in one mysql database instance? When I attempted to store Big5 encoded text in the database it converted it to UTF-8 (with useUnicode=true on the connect URL but no encoding specified). It worked when I added the characterEncoding=Big5 to my connection URL. The thing is, I need to store text data of different ecoding types and I can't change my connection URL in each case. Is this possible?