It is currently July 4th, 2022, 6:10 am

Change default encoding for newly created text documents in Windows

Tips and Tricks from the Rainmeter Community
User avatar
Active Colors
Moderator
Posts: 1126
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Change default encoding for newly created text documents in Windows

Post by Active Colors »

In Windows 10/11 when you create new text documents either from right mouse button menu New or from Notepad by default they are encoded with UTF-8 (and in Windows 7 it is ANSI).

EF2D7443-31A8-4D8D-8C07-06B17BFC4972.png
F0F0A988-E71B-4332-A038-867BB6C33AB3.jpeg
While there is no obvious way to change the default encoding of a newly created text files to a desired one, it is still possible to change it.

If you want to change the default encoding for new text files this guide is for you. In this guide I will focus on Unicode (UTF-16 LE / UTF-16 LE BOM) but you can choose another one to your liking.


1. Change the default encoding for new text documents created from the context menu "Right Mouse Click > New > Text Document".

1) Create a new text file, open it in any text editor and save this empty file with Unicode encoding:
Unicode or UTF-16 LE (Windows Notepad)
UTF-16 LE BOM (Notepad++)
UCS-2 Little Endian (other editors)

2) Rename the file to TXTUNICODE.txt and place it in C:\Windows\ShellNew (if you don't have ShellNew folder then create one)
(.txt is an extension and not a part of the name, do not make it TXTUNICODE.txt.txt).

3) Open regedit.exe
–> go to HKEY_CLASSES_ROOT\.txt\ShellNew
–> Create new String Value
–> call it FileName
–> double click it to modify
-> in the "Value Data" field type TXTUNICODE.txt

The change applies instantly.
1.png


2. Change the default encoding for new text documents created in Notepad.

1) Open regedit.exe > go to HKEY_CURRENT_USER\Software\Microsoft\Notepad

2) Right click in the directory and choose New -> DWORD (32-bit) Value, call this new value as iDefaultEncoding and double click it to modify it.

3) In the Value Data field type one of the numbers which represent encoding:
1 – ANSI
2 – UTF-16 LE
3 – UTF-16 BE
4 – UTF-8 with BOM
5 – UTF-8
in my case I choose 2.

The change applies instantly.
2.png


3. Change the default encoding for new documents created in Notepad++.

This is fairly easy and is done right from Notepad++ as well as other modern text editors. This is where it can be changed in Notepad++:

1) Open Notepad++ and go to Settings > Preferences

2) From the list of preferences select "New Document" and choose "UTF-16 Little Endian with BOM"
3.png
You do not have the required permissions to view the files attached to this post.