In the late 1990s, Microsoft was shipping two different versions of Notepad. One shipped on the 16 bit versions of Windows (Windows 95, 98, ME) while the other shipped on the true 32 bit versions (Windows NT 4.0 and Windows 2000). The 16 bit version only handled ANSI character files and only files that would fit in an edit control. I think this was 64K characters, but it could have been 32K. The 32 bit version handled both ANSI character files and Unicode characters and could theoretically handle files of up to 2^32characters.
Since Notepad should be a pretty easily used application, some design decisions were made to keep it simple and these lead to a couple of interesting bugs.
The limitation on file sizes for Windows 95 was not acceptable. I heard at one time, the Windows 95 team considered just eliminating Notepad and just shipping WordPad which handled large files and also Rich Edit format files. But WordPad had performance problems at the time and so both were shipped. Notepad was changed to run WordPad if the file to be edited was too large. This was all done under the covers, but users could see that a different program was running. It was important to have a program called Notepad because many programs had explicit references to the application. For example, setup programs would launch Notepad if the user wanted to view the License Agreement.
WordPad looks at the file contents to see if it is plain text, or rich text. Rich text has all sorts of formatting information embedded in it for things like bold, italic as well as more advanced formatting options. If the text appears to be rich text, it will display it as such. Notepad doesn't do this: it considers all text to be just characters except for the special interpretation of the end of line sequence and the character to distinguish the file as being Unicode. More about this in a future post.
So, later a bug was reported to me from that Application Compatibility team. It turns out that a program that worked just fine on Windows 95 was displaying what was considered to be garbage on Windows 2000. The non-Microsoft program was running Notepad on a text file that turned out to be rich text and the file was large enough so that Notepad on Windows 95 would run WordPad on it. Windows 95 worked file, but Windows 2000 failed. Actually, it was stranger than that. The application didn't specify Notepad, but just referred to the .TXT file. Explorer knows that to view this file means to run Notepad. If the application had named the file with the .RTF suffix, it would have worked fine on both Windows 95 and Windows 2000.
The fix could have been in either Notepad or in the app compat layer for the ShellExecute. If you fix it in Notepad, then whenever Notepad opens a file, it would scan it to see if it looked like a Rich Text file and if so, it would let WordPad handle it. The problem with this solution is that the user may have actually wanted to see the actual characters in the file, not how the file looks after WordPad has interpreted the various formatting commands in the file. In fact, you can imagine that some people may generate Rich Text files using notepad.
So, in the end, Notepad was not fixed to get around this one application problem. The fix, if I remember correctly, was put into the ShellExecute app compat layer. When the application with the error was run, when it called ShellExecute, another bit of code got run that detected this file being passed and ran WordPad instead.
Monday, October 19, 2009
Subscribe to:
Posts (Atom)