Thanks for the suggestions.
I'm already loading the rtf into a string.
It's much more complicated than you expect, though, because internally ywriter6 then converts the RTF to my own markup code. However, whenever I need to perform operations on the Rtf, I post it to a hidden rich text control, perform the ops, then convert it back to markup again.
If it were just the box in the editor it would be fine, but there are many other places I need to tackle this.
Personally I've been hoping that microsoft would update the rich text control to base it on a later one which is already included with Windows, but they haven't yet.
ScytheRider wrote:
> It is possible to preserve endash and emdash in rich text boxes.
>
> If you can get an endash into the text box, the SaveFile method saves it
> correctly. The problem is getting it in there.
>
> Instead of using the LoadFile method, load the file from a stream into a
> string.
>
> Then (for emdash) perform a replace on the raw RTF code, and replace all
> instances of "\emdash" with the string literal "???"
> Then replace all instances of "\emdash " (with a space at the end) with the
> same string literal. Then set the textbox's rtf property to the string, and
> voil??.
>
> This should perfectly preserve emdashes through saving and loading. Then
> you can do the same with "???" and \endash, or any other special character
> that gets screwed up. This is because the richtextbox converts the string
> literal into the RTF code, then the next time converts the RTF code into
> the hyphen. So if you can convert it back into a string literal before it
> gets turned into a hyphen, it's like taking a step back and then a step
> forward.
>
> For typing the characters into the editor, autocorrect does the trick just
> fine, and the textbox will not replace them.
>
> The only remaining problem is copy and paste, as the characters can get
> replaced when copying from somewhere else. If you want to go the extra
> mile, you can subclass your textbox and intercept the WM_PASTE message,
> then fetch the rtf code off the clipboard and paste it yourself after
> performing the replacements on it. This should even work with copying from
> MSWord.
>
> Or if you want an easier method, instead intercept the keypresses for
> Ctrl+V and Shift+Insert, and the right-click menu option for paste.
>
> Then you'll have a rich text box that appears to handle dashes just as well
> as any other text editor.
>
> Hope you find this helpful!