Shift+F4 Notepad UFT-8 with BOM

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
jericzech
Junior Member
Junior Member
Posts: 3
Joined: 2021-01-25, 10:39 UTC

Shift+F4 Notepad UFT-8 with BOM

Post by *jericzech »

I have set Notepad.exe as a default editor for Shift + F4 (which is the default).

I have set default encoding in Notepad.exe as UTF-8 with BOM. So when I open/create new *.txt file this encoding is used.
But using Shift + F4 the encoding is UTF-8 WITHOUT BOM.

How can I set UTF-8 with BOM defalt encoding for Shft + F4?

I don't want to use other text editors like Notepad++ or Notepad2, thought.
User avatar
nsp
Power Member
Power Member
Posts: 1913
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *nsp »

When you edit a text file you keep the current format in notepad. If you want to change encoding, just do it on save.
Default encoding, is used when creating a new file and not to change file encoding...
jericzech
Junior Member
Junior Member
Posts: 3
Joined: 2021-01-25, 10:39 UTC

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *jericzech »

OK, let me clear what I am doing. I use Shift + F4 and type name for NEW file. I am NOT editing existing one.

When I go to Save as..encoding is UTF-8 and not UTF-8 with BOM what I want and what is set as default in Notepad.

So I need to change it om every single save procedure...which is strongly inefficient as I'am creating a lot of files this way.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50421
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *ghisler(Author) »

When you use Shift+F4, TC creates a new empty file and then opens it with the configured editor. Since the file is completely empty (and also has no BOM), I guess that Notepad sees it as a UTF-8 file without BOM.
Author of Total Commander
https://www.ghisler.com
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *gdpr deleted 6 »

2ghisler(Author)
jericzech is already aware of this, or doesn't care about underlying technical details. That's why they asked:
jericzech wrote: 2021-01-25, 10:46 UTCHow can I set UTF-8 with BOM defalt encoding for Shft + F4?
and not "Why does Notepad open the new file created with Shift+F4 as UTF-8 without BOM?" ;)
User avatar
Usher
Power Member
Power Member
Posts: 1726
Joined: 2011-03-11, 10:11 UTC

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *Usher »

jericzech wrote: 2021-01-25, 10:46 UTC So when I open/create new *.txt file this encoding is used.
Do you mean that you can type

Code: Select all

notepad newfile.txt
and the new file is created in UTF-8 with BOM?
Andrzej P. Wozniak
Polish subforum moderator
jericzech
Junior Member
Junior Member
Posts: 3
Joined: 2021-01-25, 10:39 UTC

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *jericzech »

@elgonzo - thanks, you are right

@Usher - when I click Create new > Text file anywhere in Windows context menu ... and right after the new file opens I hit Save as...I see UTF-8 with BOM (without any characters in it)...I am not at the computer right now but I check your method asap
User avatar
petermad
Power Member
Power Member
Posts: 16021
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *petermad »

2jericzech
Hmm, in my Windows 7 and 8.1 Shift+F4 opens Notepad in ANSI mode, whereas in my WIndows 10 it opens in UTF-8 mode (no BOM). Which version of Windows are you using?
I have set default encoding in Notepad.exe as UTF-8 with BOM
Where do you set that - by editing Windows' Registry?

when I click Create new > Text file anywhere in Windows context menu ... and right after the new file opens
I dont see a "Create new" item in the context menu of neither TC nor Windows File Explorer nor the Desktop. There is a "New" submenu, where I can choose "Text Document" - but this function creates a new file, but it does NOT open it. If I, after it is created, open it in Notepad, the "Save as" defaults to UTF-8 (in Windows 10)
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Usher
Power Member
Power Member
Posts: 1726
Joined: 2011-03-11, 10:11 UTC

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *Usher »

2petermad
1. Only newest Windows 10 builds have UTF-8 without BOM added to Notepad, it's quite new change.
2. Older Windows 10 builds have only UTF-8 with BOM described simply "UTF-8" - like in older Windows versions.
3. In older Windows versions ANSI is default setting and you can't change it.
Andrzej P. Wozniak
Polish subforum moderator
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *Stefan2 »

jericzech wrote: 2021-01-25, 17:13 UTC

You can create your own command and assign Shift+F4 to that user defined command. Or Shift+Alt+F4, or...


FAQs: User-Defined Command (UDC) (usercmd.ini) em_command
- Create own commands to use in button or to execute them by an keyboard shortcut.
viewtopic.php?p=344777#p344777




We have done that already sometimes exactly as you need,... can be found in the forum...

I will see if I find it.

EDIT:
here is something for example > viewtopic.php?p=346569#p346569
How to:
- have your wanted file as a template
- use such an script to create an user defined command with
- assign an keyboard shortcut to that UDC to execute that script
- press the shortcut and the file template will be copied into the current active folder




 
User avatar
petermad
Power Member
Power Member
Posts: 16021
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *petermad »

2Usher
2petermad
1. Only newest Windows 10 builds have UTF-8 without BOM added to Notepad, it's quite new change.
2. Older Windows 10 builds have only UTF-8 with BOM described simply "UTF-8" - like in older Windows versions.
I know that - that is why I am asking jericzech how he has managed to set default encoding in Notepad.exe as UTF-8 with BOM

Funny thing: In Danish Windows 10, BOM is tranlated to "STYKLISTE" which means "Bill of Materials" (A list of the components and subassemblies needed to build one unit of a product) in stead of meaning "Byte Order Mark" - so Mikey$oft used a machine translation for BOM (and even capitalized the whole word to mimic BOM) - hilarious :lol:
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50421
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *ghisler(Author) »

I think the only way to do that would be to use an older version of notepad.exe. You don't need to replace the one in Windows, just put it anywhere else and link to it via menu Configuration - Options - Edit/View.
Author of Total Commander
https://www.ghisler.com
Knorke
Junior Member
Junior Member
Posts: 2
Joined: 2011-04-15, 05:58 UTC

Re: Shift+F4 Notepad UFT-8 with BOM

Post by *Knorke »

This helps in similiar cases:

Notepad of Windows 10 newer releases has the default UTF-8 without BOM.
Older versions had UTF-8 with BOM as a default.
Very old versions saved only ANSI without other alternativs.

You can change the default behave in Windows Registry:

1. Open registry using regedit.exe
2. Go to key HKEY_CURRENT_USER \ Software \ Microsoft \ Notepad
3. Create new DWORD (32-bit) key with name "iDefaultEncoding"
4. Possible values:
    1 = ANSI
    2 = UTF-16 LE
    3 = UTF-16 BE
    4 = UTF-8 mit BOM
    5 = UTF-8

[By best knowledge, worked for me, but I'm not Doctor Perfect ;-)]

But this doesn't help using Shift-F4 creating a new text file, because then notepad loads an existing file with zero length, which of course can't contain a 3 bytes long BOM. Result: Very new Notepad assumes an UTF-8 file without BOM, because this is the internal non-overwritten default.
Eventually newer (but not newest! - see above) notepad.exe could help, but I'm not 100% sure, try it!
Post Reply