Solved

Character set problem

Posted on 2006-11-02
7
1,357 Views
Last Modified: 2008-02-01
Hello,
porting an existing application to a new server with MySQL 5, when retreiving data from MySQL through Connector/J, I have encountered a weird problem: the character 0x92 (closing quote), which is correctly stored on the db, is retrieved by the jdbc driver as three characters: "’" (0xe2,0x80,0x99). The other characters, such as accenter letters, are retrieved correctly and rendered in html as ISO-8859-1.

I couldn't manage to figure out how to solve this problem in any way, so I decided make a text replace:

ret=ret.replaceAll("’","’");

but it seems not to match the three character sequence correctly.

Can anybody help me with this, or better figure out how to solve the problem at its source?

Thanks,
Fabio
0
Comment
Question by:fcanepa
  • 5
  • 2
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17859373
>>the character 0x92 (closing quote)

That's not part of the iso8859-1 character set
0
 

Author Comment

by:fcanepa
ID: 17859544
Yes, you are right. Anyway, in the old setup I didn't have to bother about character sets at all, and the character 0x92 (closing quote) was fetched correctly by jdbc and rendered correctly by apache.

But now I can't understand how to solve this strange problem. The character seems transformed in this utf-8-like three character sequence by the jdbc driver. I have logged the strings just as they are fetched from the db. If I utf-8 encode all the strings sent to the web page and set utf-8 encoding of the web page, this character will continue to give me problems, I think...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17859545
Its Unicode code is U+2019 and your jdbc driver is reading in UTF-8
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:CEHJ
ID: 17859577
The character is storable as UTF-8
0
 

Author Comment

by:fcanepa
ID: 17859677
You are right. If I log the strings immediately after fetching them from the db, also accented letters are in UTF-8. The problem is in how they are processed afterwards. I use Velocity template engine. I'll chech if it has some character set-related options. After merging the template the accented characters seems rendered as normal latin1 characters, while 0x92 is rendered as a '?'.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 17859760
You need to get Velocity using UTF-8. You can see from the 3-byte encoding that the right quote is treated correctly as UtF-8. Now you need Velocity to do so as well
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17859855
:-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Starting to learn JAVA, 7 59
Problem to start Neon 20 85
Error with Java/Cache JDBC Classpath 2 30
servlet requestdispatcher include and forward differences 1 23
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now