Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i'm using notepad++ for editing my php scripts. however i found a strange problem: when changing encoding from ANSI to UTF8 (without bom), saving, closing, re-loading - then checking encoding: is still ANSI.

any ideas what's wrong? 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

3 Answers 3

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.

imuge

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 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: http://postimage.org/image/4qza0bkv9/

Good Luck and happy programming.

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

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 are more or less the same if you only use characters that appear in ANSI. 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.

http://sourceforge.net/projects/notepad-plus/forums/forum/331754/topic/3822723


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
1  
@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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.