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
How to handle unicode data
-
- Posts: 9
- Joined: Wed 28 Nov 2007 15:57
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.
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.
-
- Posts: 9
- Joined: Wed 28 Nov 2007 15:57