Menu

Saving UTF-8 (without BOM)

alancunn
2008-07-05
2012-11-13
  • alancunn

    alancunn - 2008-07-05

    I am new to Notepad++ (after looking for an editor with more features than Notepad2, yet still simple).

    I am coding PHP and therefore cannot encode UTF-8 with a BOM since it causes headers to be sent and the whole script fails!!

    Anyway, I've two questions.

    First: What is the difference between "Format >> Encode in UTF-8 without BOM" and "Format >> Convert to UTF-8 without BOM"?  Will converting a file already in UTF-8 without BOM cause harm or does it just do nothing.

    Second: Is there a way to set all saves to use UTF-8 without BOM (rather than just setting the default for new documents).  NPP recognises the files as ANSI due to the lack of BOM, but I wish them to be saved in UTF-8 without BOM every time (without leaving it up to me to forget!!!).

    Any help would be greatly appreciated!
    Chrs

     
    • alancunn

      alancunn - 2008-07-06

      Thanks dordor,

      I think that has helped me understand the differences better.  And thanks for that warning - would have probably continued to be confused otherwise.  I'll play when I get a chance and see what I can get it to do...

      Thanks for your time!

       
    • Dor

      Dor - 2008-07-06

      1. "Format >> Encode in UTF-8 without BOM" would encode all the characters you will enter as UTF-8 and removes the BOM signature.
      "Format >> Convert to UTF-8 without BOM" would re-encode all the existing characters in your document to UTF-8 encoding. It changes the data and usually makes your file bigger if it contains non-ANSI characters.

      2. In order to make NPP "remember" the UTF-8 encoding (without or with BOM), the file must have at least 1 (one) non-ANSI character (any character that would take more than 1 byte). BEWARE, before you write non-ANSI character to a file which was NOT encoded in UTF-8 encoding, you MUST choose the "Format >> Encode in UTF-8 without BOM" option to make NPP to encode the data as UTF-8.

      Hope it helps.