Delphi, MySQL, ADOConnection - Convert database data in latin1 to utf8

2

I'm having trouble converting the strings coming from the database (Mysql - latin1) to UTF8.

The case is that I need to get the data in the database encoding for UTF8 to generate an XML with that enconding.

I tried some conversions for UTF8 after getting the data in the bank but it does not work.

I think I have to read the information in UTF8 already. Changing something in ADOConnection or ADOQuery.

Someone with experience in the subject?

Does not work:

    
asked by anonymous 02.12.2015 / 14:01

1 answer

1

Friend, I already had this problem, the easy solution was to change the connection component.

Today I use DBX which is also native to Delphi as well as what is using ADO .

You can also try this one that leaves nothing to be desired, easy to use Third Party , I'm thinking of buying an improved version of it from the developer itself!

You are doing everything right, I do not use .AsWideString , I prefer to use .AsString myself, but I believe that in your case the result will be the same, the correct one is to use UTF8Decode.

However, set another CharacterSet for your bank if you do not want to switch components!

Enjoy and add SET CHARACTER SET 'CP1251' in your connection string (if you use light), maybe it's already a path!

    
02.12.2015 / 22:39