Loading RTFData from file doesn't show quotes

Hello!

I am writing a Rich Text editor, that can save StyledText from a TextArea. Everything seems to work fine, but when I load RTFData from an RTF file, all quote characters are gone (single and/or double quotes). The odd thing is, that the quotes are still there, if I open the RTF file with Apple’s TextEdit app, so apparently my app simply ignores quotes when loading RTFData from a file. What could be the reason for this strange behaviour?

It seems that I am not allowed to use the Code button, so I have to post the code of my openFile method in plain text:

*** Begin Code ***

	Dim myFile As FolderItem
	Dim d As OpenDialog
	Dim textData As TextInputStream
	Dim rtf As StyledText
	
	Dim txtType as New FileType
	txtType.Name = "Rich-Text-Datei (*.rtf)"
	txtType.MacType = "TEXT"
	txtType.Extensions = "rtf"
	
	d = New OpenDialog
	d.Title = "Datei öffnen"
	d.Filter = txtType
	myFile = d.ShowModal
	If myFile <> Nil Then
			textData = TextInputStream.Open(myFile)
			TextArea1.StyledText.RTFData = textData.ReadAll
			TheFile = myFile
			Me.Title = TheFile.Name
			showLabel(TheFile.Name)
	End If
	TextArea1.SelStart = TextArea1.Text.Len
	TextArea1.LineSpacing = 1.15
	
	Changed = False

End Code

Kind regards,
Jens

Are they smart, or curly, quotes?

Yes, they are (German) smart quotes.

Are-they escaped ?
(value above \\'7f ? If so, in the \\'9x range ? \\'ab \\'bb ?)

Edit:
German Quote: \\'84 !

I think I could isolate the problem and create a workaround.

I used Massimos Declares (I found here in the forum) to save the RTF data to speed things up. Now I made some test runs with the Declares and/or Xojo RTF parser, and I get different results. I just typed „Test“ (with German double quotes) in the TextArea, then saved and reopened the file. The RTF data (read with Xojo’s RTFData) are:

  1. Xojo saved, Xojo reopened:
    {\rtf1\ansi\ansicpg1252{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0;}\uc0 \f0\fs28 \u8222 Test\u8220 }

  2. Xojo saved, Declares reopened:
    {\rtf1\ansi\ansicpg1252{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0;}\uc0 \f0\fs28 \u8222 Test\u8220 }

  3. Declares saved, Xojo reopened:
    {\rtf1\ansi\ansicpg1252{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0;}\uc0 \f0\fs28 \u132 Test\u147 }

  4. Declares saved, Declares reopened:
    {\rtf1\ansi\ansicpg1252{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0;}\uc0 \f0\fs28 \u132 Test\u147 }

It seems as if the Declares save the quotes differently and that they cannot be read correctly when reopening the file.
So I tried to intercept the RTFValue data before they are saved to file and replace the quotes manually, but there they are neither \u132 and \u147 or \u8222 and \8220 but \'84 and \'93.

My final solution is the following replacement in my saveFile method:

			textData = TextOutputStream.Create(myFile)
			Dim s As String = TextArea1.RTFValue
			s = ReplaceAll(s, "\\'84", "\\u8222 ")
			s = ReplaceAll(s, "\\'93", "\\u8220 ")
			textData.Write(s)

I don’t know if that’s a good solution, but at least it’s working and still way faster when saving large RTF files than the Xojo RTFData.

EDIT @Emile Schwarz: Yes, it’s MacOS.

maybe you have SmartQuotes on

https://derflounder.wordpress.com/2014/02/01/disabling-smart-quotes-in-mavericks/

Since the main hurdle with RTFData is loading, I would save Xojo, and reopen Declare. From your test it should work fine. And not require cumbersome replacements.

I think I will stick with Declare. When saving Bertrand Russells “In Praise of Idleness” (29 KB as RTF file) with Xojo it takes a little, while saving with Declare works in an instant.

@Axel: Yes, I have SmartQuotes activated and don’t want to disable it.