Community
    • Login

    Notepad++ and wrong ANSII encoding

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 5.3k 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.
    • LuciferSam86L
      LuciferSam86
      last edited by LuciferSam86

      Hello everybody : I have the following C# code which converts an UTF8 W/O BOM into an Windows-1252 textfile:

              string inputstring = File.ReadAllText(@"c:\tmp\stringa.txt");
              
      
              var srcEncoding = Encoding.UTF8;
              var destEncoding = Encoding.GetEncoding(1252);
      
              var destBytes = Encoding.Convert(srcEncoding, destEncoding, srcEncoding.GetBytes(inputstring ));
              var destString = destEncoding.GetString(destBytes);
      
              File.WriteAllBytes(@"c:\tmp\output0.txt", destBytes);
      
              return destEncoding.ToString();
      

      When I open the output0 file into Windows notepad I can see the italian accent letters right, but if I open Notepad++ the ANSI codepage is Windows-1251 and not Windows-1252.

      The original file is an UTF-8 file created with Notepad++ , and Windows is configured with the Italian codepage (1252) correctly.

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Claudia FrankC
        Claudia Frank @LuciferSam86
        last edited by

        @LuciferSam86

        may I ask which npp version (debug-info from ? menu) and windows version you use?
        How did you configure Settings->Preferences->New Document->Encoding?

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 0
        • LuciferSam86L
          LuciferSam86
          last edited by

          Hello, here the debug info:
          Notepad++ v7.5 (32-bit)
          Build time : Aug 15 2017 - 23:02:57
          Path : C:\Program Files (x86)\Notepad++\notepad++.exe
          Admin mode : OFF
          Local Conf mode : OFF
          OS : Windows 10 (64-bit)
          Plugins : mimeTools.dll NppConverter.dll NppExport.dll

          The O/S is Windows 10 Professional 64 bit Italian

          The encoding of “New Document” is:

          • UTF-8 and is enabled the sub-option “Apply to opened ANSI files”

          Thank you

          1 Reply Last reply Reply Quote 0
          • guy038G
            guy038
            last edited by guy038

            Hi @luciferqam86, @claudia-frank and All,

            Is it better if you uncheck the Autodetect character encoding option, in Settings - Preferences… - MISC ?

            Sometimes this auto-detection causes some problems, instead of avoiding them :-D

            Best Regards,

            guy038

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