23

I got an e-book reader a few months ago, and I finally figured out why it doesn't display .txt files correctly. It doesn't like ANSI. It has no problem with the other 3 types of coding notepad provides.

For a reason I chose UTF-8 and decoded all the .txt files I have on it (we are talking thousands of small but important documents). They work correctly and now I pay attention to save in UTF-8, but I know myself, I know that at some point I will forget it, and save in the default ANSI.

So the question after the small novel: Is there any way to change the default coding when saving a newly opened notepad? (Win 7)

I know about the way to change the default when opening a previously created .txt file but it's a pain to always create the new document first.

Dave
  • 25,297
  • 10
  • 57
  • 69
Emma
  • 231
  • 1
  • 2
  • 3
  • possible duplicate of [Is it possible to change the default encoding in notepad?](http://superuser.com/questions/144447/is-it-possible-to-change-the-default-encoding-in-notepad) – Kevin Panko Aug 05 '14 at 17:38

2 Answers2

17

Trying to offer a clear on-site answer:

  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

The flaw of this solution is that whenever you want to open a blank utf-8 txt document you will have to right click > New > Text Document and work from there.

Remember: Modifying the registry is dangerous! Use at your own risk.

Source

Yannis Dran
  • 345
  • 3
  • 12
  • 4
    Don't do it -- you'll save yourself some headaches down the road. Notepad technically saves the file using UTF-8 *Signature* encoding, not plain UTF-8, which adds an extra marker to the file that shows up as strange symbols in some programs like ExamDiff and can lead to unexpected results in some CSV importers, etc. – thdoan Apr 11 '17 at 12:30
  • 1
    You saved me from a big problem that hurt me for years. I feel like to create a file every day !!! :-D – Nabi K.A.Z. Sep 04 '18 at 19:29
  • 1
    @thdoan, I believe that headaches do exist because Notepad's programmers failed to recognize that utf8 is more useful than the default ANSI for most of users. If you are a programmer and need a CVS importer, you know what to do beforehand. Don't forget, default ANSI does not supports well other languages except latin. – Yannis Dran Sep 20 '18 at 09:59
  • Honestly, @thdoan, UTF-8 with (not actually a) "BOM" is fine as long as you're using modern programs, it only really breaks with older programs that can't recognise the UTF-8 signature and think it's part of the data (or in the extremely rare case where that signature is actually the first three bytes of a file that's supposed to be ANSI). ...It does waste 3 bytes during network transmission, but that's mainly because the sender can specify encoding without needing an in-file signature. – Justin Time - Reinstate Monica Jan 23 '19 at 05:14
  • @MehdiDehghani, Probably you did something wrong. Please, read again, apply with the new knowledge you acquired and come back with a useful comment so we can help your confusion out. Also, the OP hasn't been seen since Mar 27 '13 at 0:25, my answer was 2 years later. That's the reason it is not marked as a solution. The credits however belong to Mariyan, whose link in his answer does not work anymore. – Yannis Dran Jun 11 '19 at 10:18
  • @YannisDran your solution works great but it didn't change the notepad default encoding, it changes the new text document's default encoding, I never right-click, create a new file then open and edit it and then save it. I just open up notepad (e.g using Run) and save the opened file which your solution doesn't apply to this method which I think is more popular that creating new file first. – Mehdi Dehghani Jun 11 '19 at 12:38
  • @MehdiDehghani, This isn't my answer. It is a mere elaboration of Mariyan's answer, who posted a (dead) link. That's why I declare this as an "on-site answer". Also, I wrote clearly, there is a flaw (drawback) with this solution as you have to right click your mouse (for keyboard guys, there's also a keyboard right click version) anywhere in Windows and create a new text file, open it utf8-ready. In my office this is very useful as they create tons of multiple files this way. If you work exclusively with cmd, then this is simply not the answer you look for. I doubt if such a solution exists. – Yannis Dran Jun 12 '19 at 09:49
6

This here is a pretty good explanation for how to change your default encoding to UTF-8. You will need to touch the registry files though.

Personally I wouldn't bother with it. Just download Notepad++. It's free, awesome and defaults to UTF-8.

Mariyan
  • 1,397
  • 2
  • 9
  • 20
  • 2
    [Notepad2](http://www.flos-freeware.ch/notepad2.html) or [Notepad2-mod](http://code.google.com/p/notepad2-mod/downloads/list) are more lightweight. They all support set default character set encoding, and even support open 7-bit ASCII file in UTF-8 mode. – LiuYan 刘研 Feb 25 '13 at 10:18
  • Yes this is the one that only works if I previously create the .txt file. I know Notepad++ but I like the basic notepad's minimalistness, it doesn't use a lit of memory, and for what I need it works fine. Except for this thing... – Emma Feb 25 '13 at 10:25
  • 2
    In this case just follow the guide and you are good to go. Notepad++ is not at all resource heavy. It's actually the opposite. – Mariyan Feb 25 '13 at 10:39
  • Unfortunately the Microsoft link doesn't work anymore. I wonder if http://superuser.com/a/872848/74576 has the same information. – Ryan Aug 19 '16 at 19:09
  • @Ryan, I know it is late, but in case anybody looks for the info this link had, can look on my answer instead. – Yannis Dran Jun 11 '19 at 10:20