Page 1 of 1

How to handle unicode data

Posted: Thu 29 Jan 2009 07:52
by fulopattila122
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

Posted: Fri 30 Jan 2009 10:10
by Dimon
I can not reproduce the problem.
Please make sure that the UseUnicode option is set to True.

Posted: Mon 02 Feb 2009 06:31
by fulopattila122
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.

Posted: Mon 02 Feb 2009 12:38
by Dimon
Please try to compose a sample to demonstrate the problem and send it to dmitryg*devart*com.

Posted: Mon 09 Feb 2009 10:27
by fulopattila122
Hello Dimon,

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

Thank you

Posted: Mon 09 Feb 2009 14:46
by Dimon
We have answered you by e-mail.