Carriage return displayed as string of question marks inside diamonds textarea

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.

have you set a special font there?

1 Like

From where is the text you feed in the TextArea ?

2 Likes

I don’t think any special font is set.

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:

  1. For some reason TextEncoding would be wrong.

  2. 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

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

The problem is with the CR, not the constants. The constants are displayed fine.

Please post your code.

1 Like

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

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

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!���������������������������������������������������������������������������������

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

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 :laughing:

1 Like