Notepad Default encoding UTF8 Windows 10 Version 1903

Copper Contributor

 

Hello,

does anyone know if you can re-enable ANSI encoding by registry in the notepad, instead of the default UTF8 encoding, which is given since Windows 10 version 1903.

 

13 Replies

@1234598765 

 

Hi,


- use Notepad++ which is free
- OR use registry hack:

 

  1. Right click on Desktop, then choose New > Text Document
  2. A text file New Text Document.txt is created. Don't type anything and open it.
  3. Go to File > Save As... and choose UTF-8 under Encoding:, press Save and overwrite the existing file. Close the file.
  4. Rename New Text Document.txt to TXTUTF-8.txt
  5. Copy "TXTUTF-8.txt" to C:\WINDOWS\SHELLNEW
  6. Go to Start > Run... and type regedit and press ok
  7. Navigate to HKEY_CLASSES_ROOT\.txt\ShellNew
  8. Right-click in the right window > New > String Value and rename it to FileName
  9. Double click on FileName and put TXTUTF-8.txt into Value data: field and press ok

Remember, whenever you want to open a blank utf-8 txt document you will have to right click > New > Text Document and work from there.

Modifying the registry can cause serious damage pay attention, please.

@HotCakeXYour instructions are for creating a UTF-8 template document to make UTF-8 a sort of default, which is the opposite of what the OP asked for.  UTF-8 is already the default.

 

This technique will not work if the template file is empty or contains only ASCII text, as it would be byte-for-byte identical in ANSI and UTF-8.  Notepad will just use its default encoding, either ANSI or UTF-8 depending on the version

 

The template file will only be identified with the original encoding if it contains something that causes Notepad to recognize the encoding, such as a UTF-8 BOM (but the OP wants ANSI, not UTF-8), or an ANSI multi-byte sequence that cannot be reinterpreted as valid UTF-8.  For example, a text file containing only "µ" encoded as ANSI (for code page 1252, anyway) will correctly be identified as ANSI.

 

Of course, there's no need to worry about UTF-8 vs. ANSI in the first place if every file contains only ASCII text.

@lexikos 

"Of course, there's no need to worry about UTF-8 vs. ANSI in the first place if every file contains only ASCII text."

 

Wrong. If you write for example "è" in notepad, when you open the file with another text editor, you will see "è" and not "è". Then, there's need to worry about UTF-8 vs ANSI, because "è" has his ASCII code, i.e. 232

@salclem2 

 

It's not quite so easy!

Many people use Notepad for a quick .cmd/.bat file. These will not run under the command interpreter if encoded as UTF-8. The command interpreter simply gives a non-printable character plus the first character of the .cmd/.bat file and "is not recognized as a command" error if run from command prompt. If run as standalone, the window simply blinks open and closes immediately and does not execute the desired commands.

 

Anyone wanting to write a .cmd or .bat now needs to remember to save as ANSI - very inconvenient!

 

It would be very nice to have access to a key (maybe under HKCU\Software\Microsoft\Notepad) that respected the user's wishes for default coding. Or maybe Notepad could offer to set the coding as default?

 

@MalTorte 

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Notepad]
"iDefaultEncoding"=dword:00000001

; 1 = ANSI
; 2 = UTF-16 LE
; 3 = UTF-16 BE
; 4 = UTF-8 BOM
; 5 = UTF-8

@salclem2 

"è" is not an ASCII character.  ASCII only covers codes 0 to 127.  Under all ANSI code pages and UTF-8, these values have the same meaning.  A file containing only these values will be interpreted the same regardless of which code page is selected (excluding UTF-16).

@lexikos 

Not true. ASCII table code has 256 codes, from 0 to 255.

@salclem2 

 

Sorry, but @lexikos  is actually right. ASCII is a 7-bit character encoding, which means it has 2^7=128 possible values. What you mean is extended ASCII which is actually a 8-bit extension to original ASCII. This keeps the original 128 ASCII encoding and adds another 128 on top of it.

So in decimal characters 0 - 127 are original ASCII and characters 128 - 255 are extended ASCII characters.

@1234598765 

Hello,

after a big battle I realized that the solution was provided by @abbodi1406  , so I did as follows and it works like a charm:

- In Regedit go to Computer\HKEY_CURRENT_USER\Software\Microsoft\Notepad

- in the menu select edit/new/DWORD

- in the DWORD name enter iDefaultEncoding and enter value 1 as hexadecimal (it will automatically display as 0x0000001 (1) once you press OK) 

 

That's it :)

 

@lexikos  Actually ".............if every file contains only ASCII text." is correct.  ASCII is a 7 bit encoding.  Code 232 is not ASCII which is the point of @salclem2 comment.

oh god. This works. It saved me. Thanks you.
On Windows 11 a .BAT file saved as UTF-8, the default, worked fine for me.
Underrated answer. Works like a charm! Thanks!