font name not matching with stored name

I have a problem with something on my Mac not being able to set equal to the value (strg) saved in my preferences with the string value to the font’s name in my popupmenu (DFontPopUp) ONLY in the open event for my preference window. The font’s name is AppleMyongju. I have tried other names to no avail. I have no problem with matching it in my app’s open event or when I set the name via me selecting the name in the popup. When I select the font in the pops-menu, its number in the fontcount is 257, however the open event exits the FOR at 260 (of course 1 more than the count) constantly without having found the match.
MnStuff.DispFont is the property’s name and it matches everywhere but that one spot. I even added a msgbox if it wasn’t equal, just in case.

[code]//Open event for my preferences window
n= FontCount-1

For i = 0 to n//Fills the popup
DFontPopUp.AddRow Font(i)
DFontPopUp.TextFont = Font(i)
Next

If strg <> “” Then//Never sets it
n = FontCount-1
For i = 0 to n
If DFontPopUp.Text = strg Then Exit For
Next
End If[/code]

//Popupmenu.change event Dim i As Integer = me.ListIndex me.TextFont = Font(i) If me.TextFont <> MnStuff.DispFont then MsgBox "burbb”//msgbox MnStuff.DispFont = ConvertEncoding(me.TextFont, Encodings.SystemDefault)

//My app’s open event for the font setting. ts = Str(pArrayFile(rowcnt))//Font Index rowcnt = 8 ts = DecodeBase64(ts, Encodings.SystemDefault)//Font Index rowcnt = 8 i3 = FontCount -1 For i2 = 0 to i3 If ts = Font(i2) Then//correctly sets it MnStuff.DispFont = ts Exit For ElseIf i2 = i3 And Font(i2) <> ts Then MnStuff.DispFont = "Arial" End If Next

Where does strg come from? A preference file?

Sorry.

strg = MnStuff.DispFont

Strg is just a string. MnStuff.DispFont comes from the preferences file.

Check the encoding after you load that. My suspicion is that it’s Nil at that point and needs to be set to UTF8 for this to work properly.

Thank you. Solution. For an obvious reason, since XOJO used UTF8 as default, the default would be UTF8. It’s not. It’s Macintosh. Just as bad.

Since the data is coming from outside Xojo (a database) what default Xojo uses is irrelevant

When data comes from a file, serial device, network connection, database etc (something outside of your app) you should always use DefineEncoding

Thanks Norm Is there a uhmm checklist of things to consider with encodings? The list of things to consider is very complicated. I’ve grabbed things from various sources but that piece is usually not explained. The TextEncodings is very basic.

Checklist

  1. if you think it should be textual data make sure you have an encoding for your data
  2. if it came from an “outside” source (file, network connection, database, serial, etc) make sure you DefineEncoding (unless its supposed to be binary data)

This is one of the gotchas with classic framework strings
They CAN be binary data OR textual data and YOU have to recall that and remember that when you write your code
You can manipulate it either way - but this lack of separation can get you in trouble - like this thread illustrates