Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Notepad++ for editing my PHP scripts. However I found a strange problem: when changing the encoding from ANSI to UTF-8 (without BOM), saving, closing, re-loading – then checking encoding: is still ANSI.

Any ideas what's wrong? It always worked for me in the past. Thanks.

share|improve this question
If you change the encoding then make some change before saving, does that make a difference? – vincebowdren May 31 '13 at 9:23

This is expected behaviour.

It can happen that a file is saved with a certain encoding, but upon reopening it in Notepad++ it is detected with another encoding. This is a technical limitation and happens because sometimes the resulting file will not differ even though different encodings are used. This is most noticeable if the file is saved without a special BOM (Byte Order Mark) indicating the used encoding.

ANSI and UTF-8 share their first 128 characters (ASCII), making them indistinguishable if those are all you use. With a plain text file, there is no metadata indicating the encoding, so all Notepad++ (and other editors) can do is look at the characters/data in the file and take a guess.

  • If the file has a BOM, NP++ detects it and knows about the encoding.
  • If the file is HTML or XML, the encoding is read from the first line of the file.
  • Otherwise, NP++ takes a guess between UCS-2LE, UCS2-BE and ANSI. You cannot make a difference between a file encoded in UTF-8 without BOM and a file in ANSI with plenty of high ASCII characters.

In theory, PRacicot's answer should open all ANSI/UTF-8 files (without a BOM) as UTF-8. This is also recommended in an answer to a similar Stack Overflow question. If this doesn't work for you, I'm not sure what can be done. The encoding is indicated as ANSI as UTF-8 in the status bar, for me.

share|improve this answer
Makes me wonder why BOM is not recommended, when it appears that using UTF8 is highly annoying and easily subject to error without it. – Jonathon Wisnoski Mar 11 '13 at 3:38
@JonathonWisnoski I believe it's because the use of a BOM can break backwards compatibility with legacy (and other) programs expecting ASCII. In particular, many script parsers (possibly including PHP) and the shebang on some POSIX systems would trip up. – Bob Mar 31 '13 at 12:35
ANSI and UTF-8 are not more or less the same - apart from the ASCII subset, they are completely different. Trying to read a UTF-8 file (with non-ASCII characters) as ANSI will result in garbage, trying to read an ANSI file (with non-ASCII characters) as UTF-8 will most likely result in decoding errors (but can also result in garbage in some cases). – oefe Jul 3 '15 at 14:30
@oefe Edited ANSI => ASCII. – Bob Jul 3 '15 at 14:45
much better! – oefe Jul 3 '15 at 14:52

You may want to change this setting in you're notepad++ preference.

Go in the menu Settings -> Preference -> New document/ Default Directory. In the suck section Encoding, check UTF-8 without BOM and check Apply to opened ANSI files.

By checking the Apply to opened ANSI files, this preference will also be apply to current opened documents in notepad++.

Since I don't have enough points yet to post image here is a link to postimage where I uploaded the image:

Good Luck and happy programming.

share|improve this answer
thanks already did that but didn't help :( – Fuxi Jul 12 '12 at 12:24

You have to Convert to ... instead of change the Encode to ... option.
You may also want to change this option in the settings, so all your new files will get created with your choosen encoding.


share|improve this answer
thanks for your comment, already did that but didn't help. when selecting "convert to ..", saving, reloading - it's still ANSI. i also tried creating a new file and pasting. – Fuxi Jul 12 '12 at 11:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .