It is currently April 19th, 2024, 12:27 am

Change default encoding for new text files in Windows

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

Change default encoding for new text files 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 new text files to a desired one, it is still possible to change it. In this guide I will focus on changing default encoding to Unicode (UTF-16 LE / UTF-16 LE BOM) but you can choose another one to your liking.


1. Change the default encoding of 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 of new text files 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 of new text 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.
User avatar
tass_co
Posts: 512
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Change default encoding for new text files in Windows

Post by tass_co »

Active Colors wrote: February 17th, 2022, 12:11 am
11-08-2022 16_23_10-Tercihler.png
I'm sorry but I don't have "UTF-16 Little Endian wtih Bom" on hand.
What should I do?
11-08-2022 16_27_03-C__Users_Hasan Tahsin_Documents_Rainmeter_Skins_004_004.ini - Notepad++.png
You do not have the required permissions to view the files attached to this post.
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Change default encoding for new text files in Windows

Post by eclectic-tech »

tass_co wrote: August 11th, 2022, 1:26 pm 11-08-2022 16_23_10-Tercihler.png

I'm sorry but I don't have "UTF-16 Little Endian wtih Bom" on hand.
What should I do?

11-08-2022 16_27_03-C__Users_Hasan Tahsin_Documents_Rainmeter_Skins_004_004.ini - Notepad++.png
My version 8.4.4 (64-bit) of Notepad++ shows UTF-16 "Little" Endian with BOM...
Screenshot 2022-08-11 215056.png
Not sure why you have "Small" instead of "Little" in your screenshot?! Perhaps someone used a 'Replace All' command and changed "Little" to "Small"?

I would download and install a fresh copy of Notepad++ :D
You do not have the required permissions to view the files attached to this post.
User avatar
tass_co
Posts: 512
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Change default encoding for new text files in Windows

Post by tass_co »

eclectic-tech wrote: August 12th, 2022, 1:57 am My version 8.4.4 (64-bit) of Notepad++ shows UTF-16 "Little" Endian with BOM...
Screenshot 2022-08-11 215056.png
Not sure why you have "Small" instead of "Little" in your screenshot?! Perhaps someone used a 'Replace All' command and changed "Little" to "Small"?

I would download and install a fresh copy of Notepad++ :D
:D :D

I changed the language to English.
You're right, translation error... :headbang:
12-08-2022 05_30_26-C__Users_Hasan Tahsin_Documents_Rainmeter_Skins_PopupDock v5_PopupDock.ini.png
You do not have the required permissions to view the files attached to this post.
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Change default encoding for new text files in Windows

Post by Yincognito »

tass_co wrote: August 12th, 2022, 2:23 am :D :D

I changed the language to English.
You're right, translation error... :headbang:

12-08-2022 05_30_26-C__Users_Hasan Tahsin_Documents_Rainmeter_Skins_PopupDock v5_PopupDock.ini.png
Well, I could have told you that this was the right checkbox, even without knowing what the words meant. In the English version, there are only 2 UTF-16, both "with" BOM. Similarly, in your screenshot, you had 2 UTF-16 (one very big, one very small, "BOM chicka bom" going boom), and both ended up in "ile", witch was obviously the equivalent for "with" (and Google Translate, although not needed here, agrees).

Sometimes intuition is enough, not always needing to know the language. After all, that's how most people learn programming languages, when they lack other more substantial sources... ;-)

P.S. I joked a bit above, hope you don't mind - the little things (like encoding) can cause the biggest trouble, if one doesn't know what to expect. When the person finds the solution and understands the context, he usually wonders how he wasn't able to overcome such minor details. I use the same setting in Notepad++, by the way, although I also began by manually converting every little INI before realizing I could have set it as default. :lol:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
tass_co
Posts: 512
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Change default encoding for new text files in Windows

Post by tass_co »

Yincognito wrote: August 30th, 2022, 2:26 am Well, I could have told you that this was the right checkbox, even without knowing what the words meant. In the English version, there are only 2 UTF-16, both "with" BOM. Similarly, in your screenshot, you had 2 UTF-16 (one very big, one very small, "BOM chicka bom" going boom), and both ended up in "ile", witch was obviously the equivalent for "with" (and Google Translate, although not needed here, agrees).

Sometimes intuition is enough, not always needing to know the language. After all, that's how most people learn programming languages, when they lack other more substantial sources... ;-)

P.S. I joked a bit above, hope you don't mind - the little things (like encoding) can cause the biggest trouble, if one doesn't know what to expect. When the person finds the solution and understands the context, he usually wonders how he wasn't able to overcome such minor details. I use the same setting in Notepad++, by the way, although I also began by manually converting every little INI before realizing I could have set it as default. :lol:

Of course it's okay :thumbup:
From the outside it looks pretty ridiculous but when you do not know how many formats UTF has, one inevitably falls into hesitation.
Otherwise, it had already occurred to me, but I thought I'd ask anyway :thumbup:
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Change default encoding for new text files in Windows

Post by Yincognito »

tass_co wrote: August 30th, 2022, 4:37 am Of course it's okay :thumbup:
From the outside it looks pretty ridiculous but when you do not know how many formats UTF has, one inevitably falls into hesitation.
Otherwise, it had already occurred to me, but I thought I'd ask anyway :thumbup:
Not really ridiculous since we've all been through moments like that on various occasions, but funny because it reminds me of my own such moments. For example, on a couple of occasions I spent hours or days being absolutely mad that I couldn't fix something in my skins / code, and in the end it turned out to be a single "+" that had to be turned into "-", or some trivial bang that automagically solved the whole thing.

So yeah, it's no problem asking. I'm just saying that later on you'll find such instances amusing, just like I do, because looking in perspective the solution is not as hard or out of reach as you originally thought it would be. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
tass_co
Posts: 512
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Change default encoding for new text files in Windows

Post by tass_co »

Yincognito wrote: August 30th, 2022, 12:11 pm Not really ridiculous since we've all been through moments like that on various occasions, but funny because it reminds me of my own such moments. For example, on a couple of occasions I spent hours or days being absolutely mad that I couldn't fix something in my skins / code, and in the end it turned out to be a single "+" that had to be turned into "-", or some trivial bang that automagically solved the whole thing.

So yeah, it's no problem asking. I'm just saying that later on you'll find such instances amusing, just like I do, because looking in perspective the solution is not as hard or out of reach as you originally thought it would be. ;-)
Definitely :thumbup:
I don't know where i going from here, but i promise it won't be boring... :great: