Notepad bug
Posted: 02 May 2023 15:39
Hi Everyone. Long time no see. Got a new job working in the Unix world so kind of gave up on the batch file stuff. But........today my old job called me because of an issue with a text file they were viewing in notepad.
The file was nothing but a single line. A trailer record in this case as the file had no customer data. A pure ASCII file.
Position 1 has a T followed by 9 spaces and then position 11 is a 0. It is just a trailer record that tells the data system that consumes the file how many records are supposed to be in the file. In today's file the client had zero records but we still have them send an empty file with the trailer record of zero.
The file was exactly 1118 bytes according to the file size and was showing the CRLF starting in position 1117.
The file displayed fine in every other text editor but not notepad but I finally figured out a pattern to what was causing notepad to not display the file correctly.
So if the file started with any character from hex 41 to 7E in the first position of the file, followed by 767 spaces, the file would not display correctly in notepad. Remove one space from the end of the file so that it is now only 767 bytes and the file displays correctly.
Starting the file with two alpha characters or numbers was fine.
A file with 768 spaces displays fine.
A file that started with a space, any printable character and spaces out to 768 displayed fine.
From what I can tell Notepad seems to think the file is UTF16-LE when it is in this format.
Running on Windows 10. Would be interesting to see if anyone can replicate it in Windows 7 or Windows 11. We replicated it on two Windows 10 computers at my company. I could probably test on Windows Servers as well but I stay away from them like the plague these days.
The file was nothing but a single line. A trailer record in this case as the file had no customer data. A pure ASCII file.
Position 1 has a T followed by 9 spaces and then position 11 is a 0. It is just a trailer record that tells the data system that consumes the file how many records are supposed to be in the file. In today's file the client had zero records but we still have them send an empty file with the trailer record of zero.
Code: Select all
T 0 (followed by spaces all the way out to position 1116 and ending with CRLF)
The file displayed fine in every other text editor but not notepad but I finally figured out a pattern to what was causing notepad to not display the file correctly.
So if the file started with any character from hex 41 to 7E in the first position of the file, followed by 767 spaces, the file would not display correctly in notepad. Remove one space from the end of the file so that it is now only 767 bytes and the file displays correctly.
Starting the file with two alpha characters or numbers was fine.
A file with 768 spaces displays fine.
A file that started with a space, any printable character and spaces out to 768 displayed fine.
From what I can tell Notepad seems to think the file is UTF16-LE when it is in this format.
Running on Windows 10. Would be interesting to see if anyone can replicate it in Windows 7 or Windows 11. We replicated it on two Windows 10 computers at my company. I could probably test on Windows Servers as well but I stay away from them like the plague these days.