Community
    • Login

    How to set "UTF-8 WITH BOM" as default Encoding even for old but changed textfiles?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 131 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Claudia SvensonC
      Claudia Svenson
      last edited by

      As I found out I can change the default encoding for new text documents in

      Preferences—New Document—Encoding

      by enabling “UTF-8 with BOM”

      Unfortunately this works only for new, really new documents.

      When I load an existing old file (with UTF-8 only), then change something and save it, the old encoding remains.

      How can I tell NP++ to apply the new default encoding to changed old files too?

      If possible an additional option for this should be added to the next release.

      Thank you

      Alan KilbornA CoisesC 2 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Claudia Svenson
        last edited by

        @Claudia-Svenson said:

        How can I tell NP++ to apply the new default encoding to changed old files too?

        I don’t believe this is possible.

        If possible an additional option for this should be added to the next release.

        This is IMO a dubious need.


        For your use, perhaps a script that does an encoding conversion upon save would be beneficial?

        1 Reply Last reply Reply Quote 0
        • CoisesC
          Coises @Claudia Svenson
          last edited by

          @Claudia-Svenson said in How to set "UTF-8 WITH BOM" as default Encoding even for old but changed textfiles?:

          When I load an existing old file (with UTF-8 only), then change something and save it, the old encoding remains.

          How can I tell NP++ to apply the new default encoding to changed old files too?

          I think you mean you want this to be automatic; but just in case you missed it, you can change the encoding of the file while you are editing it using Encoding | Convert to UTF-8-BOM. You just have to think to do it for every file you want to change.

          1 Reply Last reply Reply Quote 3
          • Claudia SvensonC
            Claudia Svenson
            last edited by Claudia Svenson

            The problem is that it is highly recommended to store

            Powershell scripts with .ps1 extension

            and (sometimes)

            pure textfiles (ith .txt eextension

            as UTF-8 with BOM.

            In contrast it is urgently required to store

            DOS batch scripts with .bat extension

            and

            Python scripts with .py extension

            as UTF-8 WITHOUT BOM.

            I cannot count how many times I hat the wrong encoding and experienced some weird execution problems.
            Since I oftentimes use Notepad++ as initial script editor it would be the best place to auto-adjust Encoding here.

            Can I somehow let NP++ me warn when it detects a bad Encoding (depending on the current file extension) and suggest a switch? Even when I rename or edit an existing file?

            This would be a great convenient enhancement feature.

            1 Reply Last reply Reply Quote 1
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors