Link to home
Start Free TrialLog in
Avatar of fcanepa
fcanepa

asked on

Character set problem

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
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

>>the character 0x92 (closing quote)

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

ASKER

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...
Its Unicode code is U+2019 and your jdbc driver is reading in UTF-8
The character is storable as UTF-8
Avatar of fcanepa

ASKER

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 '?'.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:-)