Avatar of nobus
nobus
Flag for Belgium asked on

notepad loses formatting after saving changes

i do some translation work, and when i download the file - and do not change anything, it saves normally, formatted and all.
But when i translate some strings, all formatting get's lost when i save the file.
I have been forced to use another program -instead of the normal Windows notepad -  to have a workaround - but right now, i'd like to know WHY it happens, and if there is a cure, since it keeps coming back (i believe i even had the problem on my 32- bit OS)

i noticed that only on the file for that program - others do NOT have the problem
the file is in UTF-8 format
SoftwareWindows 7Microsoft Legacy OSWindows OS

Avatar of undefined
Last Comment
nobus

8/22/2022 - Mon
David Johnson, CD

the file is in UTF-8 format

Did you forget to change the encoding?
nobus

ASKER
what do you mean?  it is in UTF-8 and i did not change anything
what am i supposed to change ?
options are unicode - unicode big endian - ANSI
Wiesje

What ve3ofa means is that when you save the notepad file, check that you select UTF-8 in de dropdown box when using Save As.

The options I get in my notepad Save As are:
ANSI, unicode, unicdoe big endian and UTF-8.

If UTF-8 is missing from the notepad save as option list, please let us know. Perhaps it is due to the version of Windows you have.

Another very good notepad application which can do the same is Notepad++.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
nobus

ASKER
if you care to read, i posted : it is in UTF-8 and i did not change anything - meaning it is save d as UTF-8
and i know nNotepad++, it's the one i used before -as said, i want to look WHY it happensonly on this file
Wiesje

I understand that. The question I asked was: What version of Windows are you using?

And do you get the option to save as UTF-8 in your notepad version?

I do understand that the file was previously UTF-8 and that it should still be in UT-8. Why it loses it's formatting usually only occurs when it changes from type. That is why we need to know if your notepad still saves as UTF-8.
nobus

ASKER
i said i did not change it, SO IT WAS SAVED AS UTF-8
yes the option is there - i meant OTHER options were the 3 i posted
the windows i use is posted in my Question
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Wiesje

I am sorry, I cannot help you further with this problem.

I have no idea why a file would not save the layout properly, especially for this one type of file.

I wish luck in finding the answer.
SOLUTION
Darr247

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
nobus

ASKER
here is how it looks AFTER saving the file  :
goed.txt
qz8dsw

Hi Nobus, could you please update a before saving file.

Thanks
Tel
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Darr247

Well, that's not really what I asked.
e.g. here's what a procedure to make a bootable USB for Dell XP-SP3 OEM looks like in Notepad after saving it, but below that is the same procedure, simply copied and pasted from Notepad to this comment box. Notice how the formatting that 'seems' missing in Notepad has magically reappeared.

How procedure below 'looks' in Notepad

192.168.23.126:/nfs/Public      /media/MBW00      nfs      rw,timeo=10,intr      0      0


[root@AX4P3000 ~]# fdisk /dev/sdb

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-124, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-124, default 124):
Using default value 124

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 6
Changed system type of partition 1 to 6 (FAT16)

Command (m for help): a
Partition number (1-4): 1

Command (m for help): w
The partition table has been altered!

    (Remove USB stick and re-insert)

[root@AX4P3000 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              50G   41G  6.5G  87% /
tmpfs                 2.0G  384K  2.0G   1% /dev/shm
/dev/sda2             1.2G  132M 1020M  12% /boot
/dev/sda5             4.1G  3.9G   71M  99% /home
/dev/sda1              47G   26G   22G  55% /media/win7-666
/dev/sr1              5.5M  5.5M     0 100% /media/U3 System
/dev/sdb1             971M  4.0K  971M   1% /media/3810-1D5D

[root@AX4P3000 ~]# umount /dev/sdb1

[root@AX4P3000 ~]# mkdosfs -F 32 -n XPPro /dev/sdb1
mkdosfs 3.0.9 (31 Jan 2010)

[root@AX4P3000 ~]# dd if=/Temp/Dell/Dell-XPPro-wSP3.iso of=/dev/sdb bs=8M
85+1 records in
85+1 records out
718554816 bytes (719 MB) copied, 106.441 s, 6.8 MB/s







/usr/bin/livecd-iso-to-disk --format --reset-mbr /Temp/Dell/Dell-XPPro-wSP3.iso /dev/sdb

qemu -hda /dev/sdf -m 256 -vga std
Darr247

Hmmm...  I'm thinking that sample NFS /etc/fstab 'mount' command doesn't actually belong to that bootable USB procedure...  it just got mixed in because the formatting appears to be missing in Notepad.
nobus

ASKER
Darr247 i think your idea is good, - when i copy the (let's call it scrambled) scrambled txt to the comment box, the formatting reappears.
So good thing is - it's still there
Only point left : how to get it back in Notepad
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Darr247

Weirdly, if I paste it into Wordpad, the formatting is there.
Then, in Wordpad, if I use Save as on the file menu 'tab', and choose 'Other formats' then in Save as type select Unicode Text Document (with .txt extension), I get a warning that it's going to lose all formatting, which I OK through, then finish the Save... when I double-click it, it still opens in Notepad (because of the .txt association), but now the formatting is visible again.

There is no UTF-8 option in Wordpad...  but I *think* UTF-8 is a subset of Unicode, isn't it?
nobus

ASKER
where is wordpad?  i have Office 2010
Darr247

Orb/Start -> All Programs -> Accessories

The path to it in my win7 x64 is "%ProgramFiles%\Windows NT\Accessories\wordpad.exe"

But if you have Word 2010, that should work too.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
qz8dsw

Nobus any chance you can upload one of the files before you save it in notepad.
Then we can find out the original encoding thats in it.
nobus

ASKER
i copied it into Wordpad - but it was also without formatting
i attach the original file
LangFile.txt
SOLUTION
Darr247

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Darr247

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Darr247

Quite a difference, though all 3 actually have 0x0D0A rather than just 0x0A.

1 Enter character; 3 encodings
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
David Johnson, CD

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
nobus

ASKER
and what is  a solution then ve3ofa ?  (where did you find that nickname?)
nobus

ASKER
i want to say  -if i do not change anything to the file, i can save it without havving the problem; only when i replace the string after the  = sign and save it - formatting gets lost
David Johnson, CD

well for this application I'd use notepad++ and not wordpad/notepad or even word.. what was really surprising was the 2 x cr and then the lf in the original file. as for the handle it is/was my amateur radio callsign.  I'm an advanced amateur without a radio.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
SOLUTION
qz8dsw

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
nobus

ASKER
Ok guys, this looks like it's going in the right direction.
to summarise, i have 2 solutions : use notepad ++, or use notepad with word wrap off, right?

last questions : do you see any way to get the "scrambled" file to dispaly properly again?

and if i want to change the notepad exe, which Hex editor do you recommend for that?
Darr247

Wow@ the notepad bug. And it's not just in XP... I'm running Win7. I saw it happening and didn't even realize Notepad was doing it. The Notepad (v6.1.7600.16385, 192,536 bytes) in my Win7 x64 ( I don't know how to tell if it's actually a 64-bit application) does not have the string that blog article cites, so it apparently can't be fixed.

The method I described earlier -- paste into Wordpad, Save As... 'Other' ->Unicode, then open in Notepad (with Word Wrap turned off, ALWAYS from now on, I guess) and then back in Notepad using File->Save As... 'UTF-8'  seems like it should convert them back, but I don't have any files to test it on that were UTF-8 to begin with (I've always just used Unicode, not UTF-8).
qz8dsw

last questions : do you see any way to get the "scrambled" file to display properly again?

No. once the <CR><CR><LF> are gone there is no way to put them back other than manually going through the file and hitting enter where it's needed.(And that will put in the standard <CR><LF>)

And you have a 3rd option, use a hex or advanced text editor to replace all occurences of <CR><CR>  with <CR>
That would bring the file back in line with standard text and then notepad with word wrap turned on will be fine, but your other 2 options are correct. Notepad with word wrap turned off, or another editor like notepad++.

@Darr247
And you are correct, my Win7 64 bit notepad does not have the hex string either, but that is not surprising as they would not just be re-compiling it for all these years.
It can be fixed, just a different hex string so notepad would need to be debugged again to find the correct point to make the change. I'd not really call it a bug, just the method Microsoft has chosen to do word wrap so it is easily removable when saving. Unfortunately the file is using <CR><CR><LF> for end of line.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
nobus

ASKER
So the Control characters are effectively removed?

>>  , use a hex or advanced text editor   <<   Which one do you recommend?
David Johnson, CD

for your purposes an advanced text editor a hex editor is just too clunky
nobus

ASKER
ok -  But what should i use?  
notepad++ maybe?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Darr247

As shown in the screen grab posted earlier, I use XVI32 in win7 x64 without any problems.

Note I adjust the window size so it shows 16 bytes wide... that way it makes the offset addresses shown on the left side on the standard boundaries.
ASKER CERTIFIED SOLUTION
nobus

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
nobus

ASKER
i was VERY pleased with the ideas and solutions, and help offered
i sure would like to hand out more points - since you helped me understand an OLD problem, that kept reappearing

tx to all !