MySQL UTF8 encoding issue

Hey there, I have a problem.
I have an UTF8-general_ci database with a table which contains some umlauts like .
Now i want to populate it into a listbox, but I get a popup error and after I debugged it, I saw, that it doesnt handle the encoding correctly.
Here is my code:

rs=mydb.SQLSelect(sql) if not IsNull(rs) then while rs.EOF<>true lstBox.AddRow lstBox.RowTag(lstBox.LastIndex)=rs.Field("plz").IntegerValue lstBox.Cell(lstBox.LastIndex,0)=str(rs.Field("plz").IntegerValue) str=DefineEncoding(rs.Field("ort").StringValue,Encodings.UTF8) lstBox.Cell(lstBox.LastIndex,1)=str rs.MoveNext wend end if

after i changed the “.Encodings.UTF8” to “.Encodings.WindowsLatin1” but I dont understand why?! Because i am just using UTF8 nothing else.

Thanks for help in advance :slight_smile:

I don’t understand this statement - I think part of it is missing. Are you saying that it works correctly when you use WindowsLatin1? If so, how is this data saved to the database? What encoding was used then? Can you view the data correctly in MySQLWorkbench or other similar tool?

Yes i can view it correctly. It is stored as UTF8 (double checked it now) and yes with WindowsLatin1 it returns the correct data. I just dont get, why it doesnt work with UTF8 in XOJO or am i just missing some points?

When you connect to mysql initially issue one sql execute with

set names utf8

then things should be OK

Thanks @Norman Palardy that worked for me… way too easy. :stuck_out_tongue: