Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-17-2007, 05:28 PM
Member
 
Join Date: Jul 2007
Posts: 26
romina is on a distinguished road
Convert some special characters stored in a MySql
I am trying to convert some special characters stored in a MySql DB for display in Java.
Among the things I would like to convert are "á»…" to "ễ", "ç" to "ç", "ü" to "ü", etc.
My jdbc connection is
Code:
jdbc:mysql://DBL_URL/NAME?requireSSL=false&useUnicode=true&characterEncoding=UTF-8
I'v tried with no luck:
Code:
byte[] stringBytes = dbString.getBytes(); String str = new String(stringBytes , "UTF-8");
A SHOW VARIABLES LIKE 'character_set%'; in mySql produces this:
Code:
character_set_client utf8 character_set_connection utf8 character_set_database latin1 character_set_results utf8 character_set_server latin1 character_set_system utf8 character_sets_dir C:\Program Files\MySQL\MySQL Server 4.1\share\charsets/
Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 06:32 AM
Member
 
Join Date: Jul 2007
Posts: 40
trill is on a distinguished road
According to this website, latin1 is this charset: ISO-8859-1
Supported Encodings

And my charset for my MySql DB is character_set_database latin1.

So. Whatever I did to make it UTF-8 didn't work. It was still latin1 coming out. Basically, characterEncoding=UTF-8 and String str = new String(stringBytes , "UTF-8"); didn't work.

So, I finally assumed that it was latin1 coming back all the time. Here's the code that converts it to UTF-8:
Code:
private String convertStringFromLatin1ToUTF8(String stringForconversion) { try { String stringToConvert = stringForconversion; byte[] convertStringToByte = stringToConvert.getBytes("ISO-8859-1"); return new String(convertStringToByte, "UTF-8"); } catch (UnsupportedEncodingException e) { System.out.println"convert String FAILED: " + stringForconversion + "<br/>"); return stringForconversion; } }
Greetings.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedures geeta_ravikanti Database 1 04-22-2008 03:34 AM
special characters ravian New To Java 2 11-16-2007 02:28 PM
show special symbol using its Unicode character christina AWT / Swing 1 07-25-2007 10:21 AM
Special characters in text fields Felissa Web Frameworks 0 06-27-2007 05:47 PM
Stored Procedures with java Albert Database 4 06-08-2007 06:59 AM


All times are GMT +3. The time now is 12:47 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org