RichTextBox breaking ranks?

by Michael S. Kaplan, published on 2007/01/13 03:01 -05:00, original URI:

The other day someone noticed something about the WinForms RichTextBox.

What he noticed was that the RichTextBox.SaveFile method, specifically the RichTextBox.SaveFile(String, RichTextBoxStreamType) overload, was not prepending the text file with a BOM when the UnicodePlainText RichTextBoxStreamType enumeration member was passed.

He wondered whether this was a bug.

Now obviously there are lots of people outside of Microsoft (the same ones who I mentioned hate Microsoft's addition of the BOM in Notepad and other places, previously), would consider this to be the first time that we got it right since the option in StreamWriters I mentioned before.

But it is likely nothing along those lines. Just guessing, but I'd say it was probably something less strategic like just using the underlying RichEdit control's ITextDocument::Save method rather than .NET's built-in encoding support (that is the method with the bogus idea that code page 1208 is UTF-8, by the way!), which although warning that the BOM ought to be included (along with some unclear and misleading text on Unicode recommendations):

Unicode plain-text files should be saved with the Unicode byte-order mark (0xFEFF) as the first character. This character should be removed when the file is read in; that is, it is only used for import/export to identify the plain text as Unicode and to identify the byte order of that text. Microsoft Notepad adopted this convention, which is now recommended by the Unicode standard. 

I didn't look at the RichTextBox source, but it is hardly an accident that so many of its properties and methods map to properties/methods/messages on the underlying RichEdit control.

So anyway, I'd say it's not a bug. But the fact that you don't have the option to include the BOM does seem to be a bit of breaking ranks from what Microsoft has usually done here....


This post is sponsored by U+feff (ZERO WIDTH NO-BREAK SPACE)

no comments

go to newer or older post, or back to index or month or day