RobertF
(RobertF)
July 5, 2022, 4:36pm
1
My textarea displays a string of characters that have a question mark inside a diamond for the carriage return (or linefeed). I tried using:
-AddText instead of ‘+’
-AppendText
-Specifying UTF-8, such as:
sCR = DefineEncoding(Chr(13), Encodings.UTF8)
or
sCR = DefineEncoding(String.ChrByte(13), Encodings.UTF8)
None make a difference.
MarkusR
(MarkusR)
July 5, 2022, 4:52pm
2
have you set a special font there?
1 Like
From where is the text you feed in the TextArea ?
2 Likes
RobertF
(RobertF)
July 5, 2022, 5:38pm
4
I don’t think any special font is set.
RobertF
(RobertF)
July 5, 2022, 5:39pm
5
The text is just a constant from the source. All texts are fine, except the CR and or LF, as far as my usage is concerned.
Looks like at runtime Xojo is not able to figure out what CR and LF are. I see two possibilities:
For some reason TextEncoding would be wrong.
The TextArea contents was set using on an OS different than the one you use for reading the TextArea
Windows and macOS use different enOfLine markers that cause issues. But on a second thought, you wouldn’t see ? in a Diamond.
I suggest displaying the TextArea in the debugger in the Hex Tab to check the characters that are displayed as ? in a Diamond.
1 Like
RobertF
(RobertF)
July 5, 2022, 5:56pm
7
Thanks. I forgot to include this info in the previous posts: The CR is shown as this sequence:
ef bf bd
for each CR.
Where are you getting the original text from?
Are you sure of the encoding?
1 Like
A constant is not UTF8. You must DefineEncoding it when you feed it to the TextArea. If it comes from another source than Xojo itself, you may need to ConvertEncoding.
1 Like
RobertF
(RobertF)
July 5, 2022, 6:18pm
10
The problem is with the CR, not the constants. The constants are displayed fine.
RobertF
(RobertF)
July 5, 2022, 6:20pm
12
sCR = DefineEncoding(Chr(13), Encodings.UTF8)
Window_log.TextArea_log.AddText(“Hello, world!”)
Window_log.TextArea_log.AddText(sCR)
Xojo has a way of dealing with EndOfLine since the platforms have different means of doing so.
You may wish to review the EndOfLine function and the ReplaceLineEndings function .
1 Like
RobertF
(RobertF)
July 5, 2022, 6:24pm
14
I did try EndOfLine, no difference. Will try ReplaceLineEndings now.
Thanks.
Try this instead:
sCR = EndOfLine
I am assuming addText is something like TextArea_log.Text = TextArea_log.Text + whatever.
Note that Chr(13) is endofLine.macOS.
EndOfLine.Windows is chr(13) + chr(10)
EndOfLine without the platform is the default for the platform under which the program executes.
2 Likes
RobertF
(RobertF)
July 5, 2022, 6:36pm
16
Thanks, Michel. EndOfLine has the same result. Even with the correct platform, macOS; or default.
The output has a sequence of ?-in-diamond chars, not just one:
Hello, world!���������������������������������������������������������������������������������
AlbertoD
(AlbertoD)
July 5, 2022, 6:41pm
17
Can you share a simple sample that people can download and reproduce your problem? You can use dropbox, google, microsoft or other share service.
1 Like
RobertF
(RobertF)
July 5, 2022, 6:45pm
18
TextArea_log is a TextArea
Window_log.TextArea_log.AddText(“Hello, world!”)
Window_log.TextArea_log.AddText(EndOfLine.macOS)
Please try using TextArea1.Text = "Hello" + EndOfLine + "World"
It really should be that simple.
1 Like
@Tim_Parnell
I got the same google result as you and was posting but saw you beat me to it
1 Like