Using End OF Line in a MessageDialog is Showing the Char with a Question Mark for each endofline.
if YNQuestion("Found " + rs.Field("Name").StringValue + "." + EndOfLine + EndOfLine + "Is this the correct person?") <>"Yes" then
'Here's the function
Function YNQuestion(sMessage as String, sExplanation as String = "") As String
Dim d as New MessageDialog //declare the MessageDialog object
Dim b as MessageDialogButton //for handling the result
d.icon=MessageDialog.GraphicCaution //display warning icon
d.ActionButton.Caption="Yes"
d.CancelButton.Visible=True //show the Cancel button
d.AlternateActionButton.Visible=True //show the "Don't Save" button
d.AlternateActionButton.Caption="No"
d.Message = sMessage
d.Explanation = sExplanation
b=d.ShowModal //display the dialog & return pressed button
Select Case b //determine which button was pressed.
Case d.ActionButton
Return "Yes"
Case d.AlternateActionButton
Return "No"
Case d.CancelButton
Return "Cancel"
End select
End Function
I tried the .Windows, .OSX, .Unix and .Macintosh, no change.
What is causing this. I don’t remember it being a problem before???
No, each string has it’s own encoding, and since you’re getting at least part of it out of your database, it’s probably supposed to be UTF8.
Try this at the top of your function:
if sMessage.Encoding = nil then
sMessage = sMessage.DefineEncoding( Encodings.UTF8 )
else
sMessage = sMessage.ConvertEncoding( Encodings.UTF8 )
end if
In the M_String package on my web site, I have a function that will analyze a string and return the best encoding for it. If you were to use that, your code would look like this:
if sMessage.Encoding = nil then
sMessage = sMessage.DefineEncoding( M_Encoding.ByAnalysis( sMessage ) )
end if
sMessage = sMessage.ConvertEncoding( Encodings.UTF8 )
[quote=33420:@Richard Albrecht] if YNQuestion("Found " + rs.Field(“Name”).StringValue + “.” + EndOfLine + EndOfLine + “Is this the correct person?”) <>“Yes” then
[/quote]
If you don’t define the encoding of the data coming in from external source - like a database record - then this string likely has a nil encoding
You can verify this by putting a break point on the very first line of code in YNQuestion & examining the string sMessage
I suspect it has a nil encoding & making everything be UTF-8 may work but may not be right
You’d be better off making sure that where ever you access the data in a recordset and get a value from it you DO define the encoding of the data.
Any time you get data from something outside your program - a database, a serial port, a file, etc - you could call define encoding on that data and the rest of your code and just deal with it as strings that DO have encodings
Also, try avoiding multi-line text for the “Message”, as that’s supposed to be just the subject title of the dialog. Instead, put the additional text into the Explanation. There, EndOfLines should work better.
“Any time you get data from something outside your program - a database, a serial port, a file, etc - you could call define encoding on that data and the rest of your code and just deal with it as strings that DO have encodings”