Delphi, Mysql, Adoconnection - Convert database data from latin1 to utf8

Asked

Viewed 319 times

2

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

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

I tried some conversions to UTF8 after picking up the data in the database but it doesn’t work.

I believe I already have to read the information in UTF8. Changing something in Adoconnection or Adoquery.

Someone with experience in the subject?

Doesn’t work:

inserir a descrição da imagem aqui

1 answer

1

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

Today I use the 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 Third Component, easy to use, I’m even thinking of buying an improved version of it from the developer company itself!

You’re doing all right, I don’t use .AsWideString, I prefer to use the .AsString even, however, I believe that in your case the result will be the same, the correct is to use the Utf8decode.

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

Enjoy and add in your connection string (if you use of course) the SET CHARACTER SET 'CP1251', maybe it’s already a way!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.