PopupMenu and encoding

I am filling a PopupMenu from a MySQL database by going through the records and using Popupmenu.AddRow for each returned record.

This works well, but some characters have problems. In particular, the degrees symbol, °, gets turned into some kind of odd character. Elsewhere in the app, I can tack “.DefineEncoding(Encodings.ISOLatin1)” onto the end of the field value and it shows up correctly in a list or text box. But even if I do this:

LocationSelect.AddRow(resultsL.Field("display").StringValue.DefineEncoding(Encodings.ISOLatin1))
It still shows up mangled.

I can type a degree symbol into the InitialValue, and it shows up correctly.

But there is something peculiar going on here. Any thoughts?

Thanks,

–Lyle

Break it out, step through, and see where it’s not turning into the expected symbol.

[code]dim sTemp as String = resultsL.Field(“display”).StringValue
sTemp = DefineEncoding(sTemp, Encodings.ISOLatin1)

LocationSelect.AddRow(sTemp)
[/code]

Are you setting the encoding to ISOLatin1 because that’s how the database is encoded? If not, you should use the same encoding as the database. Not doing so can cause issues like this.

Also, you should define the encoding for all strings from an external source, be it a database, text file or anything else.

Have you tried converting it to UTF-8 after defining it as Latin1?

Have you tried converting it to UTF-8 before defining it as Latin1? *

I define all external data into UTF-8 (this is the 21st century) and never had a trouble since then.

  • Use that (UTF-8) excepted if you really have to use Latin1 for a known and valuable reason (some target need that encoding), else, use UTF-8.