RTF trouble

  1. 3 months ago

    (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

    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.

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

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

  4. @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.

  5. BBEDIT (latest version)

    {\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}

  6. @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.

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

  8. Emile S

    Jul 6 Europe (France, Strasbourg)
    Edited 3 months ago

    @Stéphane ;Mons NOT TextEdit because it would convert the file

    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 Apple’s TextEdit will have trouble when loaded with Xojo…

    A well know bug.

  9. 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 ! ?

  10. Emile S

    Jul 6 Europe (France, Strasbourg)
    Edited 3 months ago

    @Enric H Thanks Emile, but is there a solution? ,

    Yes:

    @Emile S store the rtf files wth a Xojo generated application

    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.

  11. @Emile S just have to add a size and style changer.

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

  12. Enric H

    Jul 6 Answer

    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.

  13. Emile S

    Jul 6 Europe (France, Strasbourg)
    Edited 3 months ago

    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://docs.xojo.com/TextArea

  14. @Emile S 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.

    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

  15. Emile S

    Jul 6 Europe (France, Strasbourg)
    Edited 3 months ago

    @Enric H all other formatting were correct.

    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.

  16. oh, I use Mojave.

  17. Emile S

    Jul 6 Europe (France, Strasbourg)

    Nice. A reason to update from El Capitan…

or Sign Up to reply!