RTF trouble

(MacOS)
A TextEdit saved as .rtf is to be show in a textArea:
The original text is (it’s just an exemple):

it’s late
I can’t

But it’s show as

it?s late
I can?t

the ’ disapeared

Sub Open() Handles Open Dim textData As TextInputStream Dim f As FolderItem = SpecialFolder.GetResource("help.rtf") If f <> Nil then textData = TextInputStream.open(f) me.StyledText.RTFData = textData.ReadAll textData.Close End If End Sub

@Enric Herrera — Could it be related to this? You should inspect your RTF file to see which encoding it requires.

It’s bizarre because all other characters, for example " , , , etc." are show correct, it’s only the < ’ > that is ignored.
If the RTF is opened by Pages, Word, etc it’s show correct only in Xojo textArea is not.

@Enric Herrera — Well Pages and Word use proprietary algorithms, so you cannot compare them with macOS. Open your RTF file in a raw text editor like BBEdit (NOT TextEdit because it would convert the file) and tell us what you see.

BBEDIT (latest version)

[quote]{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf500
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0

\f0\fs24 \cf0 it\'92s late\
it can\'92t bw done}[/quote]

@Enric Herrera — So, like in the link I gave you, your RTF file calls for ANSI characters (look at the “\ansicpg1252” part on the first line). Apparently, StyledText.RTFData is not able to accept such data.

So, which is the solution?

How may I write something like:

it’s late
it can’t be done
à, á, è, é, í, ò, ó, ü,
I’m here

That’s not showed as:

it?s late
it can?t be done
à, á, è, é, í, ò, ó, ü,
I?m here

Wrong assumption !

There is a preference to allow you to load a rtf file as raw text Change it, then load the file and reverse the setting.

Same apply for html files

Enric: unlike what I wrongly understand, the rtf file does not comes from your TextField. That is the reason why you get troubles. (my bad).

In short, store the rtf files wth Xojo generated applications, then you will not get troubles. RTF files generated with Apples TextEdit will have trouble when loaded with Xojo

A well know bug.

Thanks Emile, but is there a solution? ,
I need to write several files with several formatting text (bold, cursive, biggest, fonts, etc,), and then show them in a textArea. Do I need to create an Editor in Xojo to export RTF to be read with Xojo ! ?

Yes:

and it is easy to do it, you already have the file io, just have to add a size and style changer.

Or, if you are fluent in rtf coding, you can change the rtf data in RTF source, but I prefer the first solution.

Sorry for my ignorance, but can you explain I little more the meaning?

I did the following and it seems to work, I post it because maybe could help to anyone.

In TextEdit preferences/open and Save, check “Display RTF files as RTF code…” as Emile suggested.
Then load the .rtf file
In the Edit menu select Find and replace
Find: \'92
replace: ’
Then replace all and save as RTF normal.
Then when opened in Xojo, with the code I posted at the begin of this conversation it works.

In TextEdit, you can (ike in any Word Processor), you can change the TextSize, TextFont, TextStyle (Bold, Italic, etc.).

Look TextArea in the LR for more explanation / sample code to do that in Xojo.

http://documentation.xojo.com/api/deprecated/textarea.html

[quote=444433:@Emile Schwarz]In TextEdit, you ca (ike in any Word Processor), you can change the TextSize, TextFont, TextStyle (Bold, Italic, etc.).

Look TextArea in the LR for more explanation / sample code to do that.[/quote]
Sure, in fact the RTF files were generated with TexEdit with all formatting needed.
The problem, and the only one, was that the character " ’ " disappears and where it’s written: I’m here looks Im here, all other formatting were correct.

probably TextEdit uses a strange char. \'92

No (not with El Capitan).

The curly ’ (’) also is bad and so are éè and some others…

BTW: if the trouble is only with the standard apostrophe (’), use the curly one (Option-’), check with the Keyboard visualizer (if this is the original name) that display a keyboard on screen.

oh, I use Mojave.

Nice. A reason to update from El Capitan…