How to handle unicode data

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for MySQL in Delphi and C++Builder
Post Reply
fulopattila122
Posts: 9
Joined: Wed 28 Nov 2007 15:57

How to handle unicode data

Post by fulopattila122 » Thu 29 Jan 2009 07:52

Hello,

I'm using the v4.40.0.14 dbExpress for MySQL driver and trying to access a database using utf8 charset with Delphi 2009.

I saw in the readme the CRSQLConnection can handle Extra options and I have set them in Params:
UseUnicode=True
Charset=utf8

When I add all the Fields (on TSQLQuery) varchar fields get mapped to TStringField therefore accented characters are not displayed properly.
AFAIK they should be mapped to TWideStringField. I could not figure out what to do in order to achieve this.

Just a sidenote: When using the built-in CodeGear MySQL driver I have to set the parameter ServerCharSet=utf8 on the SQLConnection to get the expected result (varchar to be mapped to TWideStringField)

Thank you

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 30 Jan 2009 10:10

I can not reproduce the problem.
Please make sure that the UseUnicode option is set to True.

fulopattila122
Posts: 9
Joined: Wed 28 Nov 2007 15:57

Post by fulopattila122 » Mon 02 Feb 2009 06:31

Thanks, you're right. I made a new test application, set the extra option and it does the job!

But on the old app still doesn't, don't ask me why :)
I had to delete the SQLConnection component and drop a new one on the form.. Interesting..

Now the problem left is that accented charachters don't display properly. I know delphi 2009 uses UTF16 and my db is utf8, but I couldn't figure out how to convert it. As far as I understand Delphi should do it automatically, but it doesn't. I tried converting with UTF8ToWideString() manually, but it doesn't convert to the correct characters either. I'm lost :-|

Anyways, thanks for your help again.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 02 Feb 2009 12:38

Please try to compose a sample to demonstrate the problem and send it to dmitryg*devart*com.

fulopattila122
Posts: 9
Joined: Wed 28 Nov 2007 15:57

Post by fulopattila122 » Mon 09 Feb 2009 10:27

Hello Dimon,

E-mail sent, please let me know if that doesn't reach to you.

Thank you

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 09 Feb 2009 14:46

We have answered you by e-mail.

Post Reply