UTF8 text is displayed differently in Combobox and Listbox

I have a MySQL database with UTF8 format.
When I save the data from a textfield or a Listbox it is saved correctly in UTF8 in the database, but when I read that data again, in the listbox they appear correctly but in a combobox strange characters appear in letters with accents, apostrophes, Umlaut, degree symbol, etc.
I do not make any kind of conversion in the whole process.
Combobox need a different treatment than the listbox to correctly display words in UTF8 format?

No but I would bet that when you retrieve the data you never call DefineEncoding on it do you ?
Without that its just “bytes”

Xojo is supposed to treat the text as utf8 natively.
Why in a ListBox the text (including accents and others) appear correctly and not in a Combobox?
What code or function should I use?

I think I found the problem:
If I use (mbp is a Combobox):

c1 = DefineEncoding(rs.Field("MEDIDA").stringValue,Encodings.utf8)
c2 = rs.Field("ENGRANAJE").stringValue 'data saved as integer in the database

mbp.AddRow c1+" - "+c2+"Cm"

The text in c1 string var is displayed with strange chars.
But if I use:

c1 = DefineEncoding(rs.Field("MEDIDA").stringValue,Encodings.utf8)
c2 = DefineEncoding(rs.Field("ENGRANAJE").stringValue,Encodings.utf8) 'data saved as integer in the database

mbp.AddRow c1+" - "+c2+"Cm"

The text in c1 string var is displayed correctly!!!
I do not know why.

It does - when you properly set the encoding as BEING UTF-8
When you get data from a database its basically treated as “a pile of bytes”
So you need to tell Xojo that this pile of bytes should be handled as though it is UTF-8

Thats what DefineEncoding does

Any time you get data from outside sources (files, databases, serial, tcp etc) and you want to treat its as “string” data you need to Define The encoding otherwise it could have a nil encoding and you end up with the effect you see

See Why are there diamonds in my user interface? – Xojo Programming Blog

Thanks Norman.

The problem (solved) is that when I concatenate a string defined with DefineEncoding with an undefined string (an integer passed to string), the string resulting from the concatenation loses the format utf8.

Definitely since its NOT clear that all the bytes can be interpreted as UTF-8