Why does Notepad NOT open a specific text file correctly?

R

Robert Macy

Is this a bug?

Both files started out as Matlab like data files saved in ascii mode,
one named f.txt, the other g.txt Both files in their original state
read properly. Both files consist of all printable characters with
header lines [each header line begins with the character #] followed by
simple integer values, separated by spaces. I needed to remove the
header lines, so I opened each using Notepad, and deleted the five
header lines, leaving only the integer values.

The first file reads after the header lines are removed with NO
problem. The second, and similar file, does not read correctly again
using WinXP Notepad. Notepad only shows a long series of single little
zero like characters. It does not show the data that is known to be
contained in the file.

Win98Se Notepad opens the file properly. Hex editor opens the file and
clearly shows that the characters are all printable ascii 20 32 30 33
20 etc, and another editor, Sc1 opens it properly, only Notepad in the
WinXP does not like this specific file after it has been modified.
Actually, didn't matter how the file got modified, whether done by
WinXP Notepad or another editor, once the header lines are gone,
Notepad on the WinXP doesn't read the file properly again.

Any ideas? Is this some kind of bug?

- Robert -
 
R

Robert Macy

Callmark1 said:
Try "copy and Paste" into a new notepad file.

Pasting to a new .txt file and attempting to save that did not work.
Keep in mind that the original file is strictly spaces and integers and
that's all. Here is what this file looks like...
202 203 205 206 208 209 211 212 215 217 218 220 221 223 224
....there are more numbers with the last being cr lf, like a normal
line.

First, WinXP Notepad would not let me save the pasted file, without
answering some stupid question about ANSI versus saving as UNICODE.
[This file only contains spaces and integers, nothing else] and how if
I didn't do it right it would change my file [which it did do]

If I save the file as unicode, it still comes up all little zeros, but
when viewed on the Win98 Notepad, the data seems to be intact, but two
characters were added at the front of the file [actually making it
slightly bigger] The added characters were ff & fe whose purpose is
unknown. After those two characters the rest of the file appeared to
be intact.

But even this saved file still opens as all zeros in the WinXP Notepad

However, if I force the save to be ANSI, it seems to destroy the file.
It then opens with a long series of ?????? and is indeed destroyed.
Even Win98 notepad no longer has characters in it. just ?????

Forgot to mention that WinXP WordPad opens the file properly, but it's
difficult to get it to do that since .txt files are linked to be opened
with Notepad. However, Wordpad opens the pasted and saved file as all
little zero squares. So Notepad has ruined the file.

Again, this all came about because Notepad was used to open, edit, and
save two similar files. One, which is almost identical has no problems.
BUT...*If* this file has its header lines all is ok. After opening,
Notepad will nicely highlight those header lines and I delete them.
Notepad still is showing the data intact. Then after saving, closing
Notepad application, and reopening by clicking on the file. Notepad
loses its mind. Can't properly reopen something Notepad was just
looking at earlier.

Is this a bug?

- Robert -
 
D

Doug

So save the file using "Wordpad" and not "Notepad" if "it"
screws up the file. Where is the problem?

Doug W.

Robert Macy said:
Callmark1 said:
Try "copy and Paste" into a new notepad file.

Pasting to a new .txt file and attempting to save that did not
work.
Keep in mind that the original file is strictly spaces and
integers and
that's all. Here is what this file looks like...
202 203 205 206 208 209 211 212 215 217 218 220 221 223 224
...there are more numbers with the last being cr lf, like a
normal
line.

First, WinXP Notepad would not let me save the pasted file,
without
answering some stupid question about ANSI versus saving as
UNICODE.
[This file only contains spaces and integers, nothing else]
and how if
I didn't do it right it would change my file [which it did do]

If I save the file as unicode, it still comes up all little
zeros, but
when viewed on the Win98 Notepad, the data seems to be intact,
but two
characters were added at the front of the file [actually
making it
slightly bigger] The added characters were ff & fe whose
purpose is
unknown. After those two characters the rest of the file
appeared to
be intact.

But even this saved file still opens as all zeros in the WinXP
Notepad

However, if I force the save to be ANSI, it seems to destroy
the file.
It then opens with a long series of ?????? and is indeed
destroyed.
Even Win98 notepad no longer has characters in it. just ?????

Forgot to mention that WinXP WordPad opens the file properly,
but it's
difficult to get it to do that since .txt files are linked to
be opened
with Notepad. However, Wordpad opens the pasted and saved
file as all
little zero squares. So Notepad has ruined the file.

Again, this all came about because Notepad was used to open,
edit, and
save two similar files. One, which is almost identical has no
problems.
BUT...*If* this file has its header lines all is ok. After
opening,
Notepad will nicely highlight those header lines and I delete
them.
Notepad still is showing the data intact. Then after saving,
closing
Notepad application, and reopening by clicking on the file.
Notepad
loses its mind. Can't properly reopen something Notepad was
just
looking at earlier.

Is this a bug?

- Robert -
 
R

Robert Macy

Doug said:
So save the file using "Wordpad" and not "Notepad" if "it"
screws up the file. Where is the problem?

One more time. Notepad is automatically linked to .txt files.

Doubling clicking to open the file opens it with Notepad. This is ok.
For the first time, as the header lines are removed. The viewing is
correct. Save, reopen with a double click and the file is NOT
presented correctly, although investigation shows that the file is
correct and Notepad has failed. So, the first saving with Notepad is
correct. It just can't be verified later using Notepad.

Right click on the name of the file to select "open with" does NOT
work, instead it opens only with Notepad. Ok, Open with Wordpad. That
means go find Wordpad somewhere, and clicking and clicking and clicking
until I can get the file open. Quite frankly I don't enjoy spending
productive time needlessly playing with a tool that should simply work.
And I don't want Wordpad to open ALL the .txt files, either.

That's the problem.

So, is this a bug?

- Robert -
 
H

HeyBub

Robert said:
One more time. Notepad is automatically linked to .txt files.

Doubling clicking to open the file opens it with Notepad. This is ok.
For the first time, as the header lines are removed. The viewing is
correct. Save, reopen with a double click and the file is NOT
presented correctly, although investigation shows that the file is
correct and Notepad has failed. So, the first saving with Notepad is
correct. It just can't be verified later using Notepad.

Right click on the name of the file to select "open with" does NOT
work, instead it opens only with Notepad. Ok, Open with Wordpad.
That means go find Wordpad somewhere, and clicking and clicking and
clicking until I can get the file open. Quite frankly I don't enjoy
spending productive time needlessly playing with a tool that should
simply work. And I don't want Wordpad to open ALL the .txt files,
either.

That's the problem.

So, is this a bug?

Unlikely, since Notepad is used, literally, billions of times a day.
Further, you say Notepad works on one file but not on another.

Seems like the problem is data dependent: for example, Notepad has data
limitations not found in Wordpad.

And you don't have to "find Wordpad." XP knows were it is.
 
R

Robert Macy

HeyBub said:
And you don't have to "find Wordpad." XP knows were it is.

You are right that there must be something in the pattern of TEXT data
that upsets Notepad as it tries to open this particular file.

For some reason, this file now comes up with three choices for opening
it with a "right click" which simplifies things a bit.
Notepad
Wordpad
Sc1

fairly simple now. only two clicks to get it opened correctly.

But still,...it makes me nervous when applications don't work the way
they're expected to work.

- Robert -
 
S

Seahawk60B

There's obviously something different in the second file that is making
notepad treat it differently. When you try to paste it in a new text
file, are you creating the blank file first, or just launching notepad
with a new, yet-to-be saved file. Does it behave differently if you
create a new blank .txt file first, then open that (which should be
ANSI by default), then paste the data into that? What if you copy the
notepad.exe from the Windows 98 box to the XP box as notepad98.exe or
such - Will the notepad98.exe open and save it correctly?
 
R

Robert Macy

Seahawk60B said:
There's obviously something different in the second file that is making
notepad treat it differently. When you try to paste it in a new text
file, are you creating the blank file first, or just launching notepad
with a new, yet-to-be saved file. Does it behave differently if you
create a new blank .txt file first, then open that (which should be
ANSI by default), then paste the data into that? What if you copy the
notepad.exe from the Windows 98 box to the XP box as notepad98.exe or
such - Will the notepad98.exe open and save it correctly?

Perhaps it's just my machine. I can zip the files and send them to
you. Even in ascii they're only around 2KB to 3KB each. I don't need
to zip them. See how your system reads them, perhaps it's just some
initial setup in WinXP that wasn't done correctly.

send request to
macy
...AT..
california
...DOT..
com

I keep files called $blank.txt lying around so I can cut and paste
tidbits as I run across them. Simply "save as" and it's done. Things
like URLs for special information, historical ongoing emails from
people - so it's all in one place. The beauty of .txt is that when the
change from IE4 went to IE5 went to IE6 didn't matter. All was right
there easy archives, easy retrievals. And much smaller memory.

The paste was into an already existing $blank.txt. [Remember Notepad
originally created this file by editing/deleting the header lines. And
saved the file with no special questions, just standard save]] After
reopening and pasting the file into the existing blank.txt file, that's
when Notepad permanently started mucking the file up. And worse asking
questions, expecting answers, without giving any explanations for what
was going on.

Don't know about copying Notepad98.exe I'm not impressed with WinXP
compared to the performance I get from Win98. I bought XP
Professional, but it's likely to be remanded to the trash heap soon.
XP seems be slower, bloated code. have less control, etc. Sadly, it
seems so much historical code is being used that the CPU probably runs
around duplicating efforts. Not until an OS is built from the ground
up again will that get cleaned up very well.

However, WinXP is forgiving when I run C++ programs during development
that're not quite right and bomb things badly. Only once did WinXP
bomb so badly it unrecoverably changed something - don't know what, so
I had to reinstall. But considering the "damage" the offending program
probably did, that was surprising that's all that happened.

I'm still not sure what advantages I'm supposed to see in XP. Just
not obvious to me. Except I definitely have better presentations due
to ads and pop ups and such. In other words, XP makes me a better
recipient of advertising. But that's not my goal in life. Actually, I
keep tripping over WinXP "improvements". Like this Notepad problem.
and Unicode, etc. [I still haven't sorted out how to organize the open
applications icons to prevent XP from "lumping" them inappropriately]
Many really irksome traits are still there. Like naming folders "My
Documents, My Music, My this, My that and then forcing me to use those
folders first.

Let me know if you'd like to look at the pure text file that causes my
Notepad to go strange. The misread file is around 2KB. The other,
similar, coreectly reading file is around 3KB, slightly larger but
contains the same number of integers, 400, in a single line with single
spaces between.

- Robert -
 
S

Seahawk60B

I'd be happy to look at the files for you - you can send them to
sh2fpilot at
charter dot net
Sometimes that second pair of eyes helps reveal something...
 
R

Robert Macy

Seahawk60B said:
I'd be happy to look at the files for you - you can send them to
sh2fpilot at
charter dot net
Sometimes that second pair of eyes helps reveal something...

Exactly.

I'll send both to you.

The one that works is f400.txt, the one that doesn't is g400.txt

I'm sending all four. The two before modification WITH the header
lines, the two AFTER modification with the header files stripped. That
way you can try modifying th originals, too.

- Robert -
 
S

Seahawk60B

Robert,

I don't know that I can fully explain why, but I can tell you what
appears to be happening. When I saved the file as Unicode or UTF-8,
they opened properly. When I looked at the differences in the hex
between ANSI, UTF-8, and Unicode, I noticed that UTF-8 and Unicode
included a header before the data. I did a search on ANSI encoding in
Windows notepad and found the following post:

http://forums.wincustomize.com/index.aspx?AID=117870

Basically, there are other ways to "break" notepad as well. When I
opened notepad by itself, then went to file- open I noticed that for
f400.txt, it was defaulting to ANSI, which is correct, since that was
the encoding that was selected when it was saved. However, the
g400.txt was defaulting to Unicode. By changing it to ANSI in the file
-open dialog box the file opens properly. For some reason, when
notepad goes to open the file, it is having trouble determining the
correct encoding, and is defaulting to Unicode.

According to one of the posts in the above link, if you delete the
squares and repaste the information, it will save and open correctly.
Looking at the hex code, I believe this is due to the fact that once it
opens it as Unicode, when you repaste the data and save it, it saves as
Unicode, and inserts the proper code before the data.

So your options would seem to be
1) use a different text editor as your default
2) specify the encoding as Unicode when saving

As a side note, a program I use for saving snippets of information is
Treepad (www.treepad.com). There is a lite version that is freeware,
it's a slick program in that you can organize and save all your
information, and it's fully searchable making it easier to find it
later.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top