• Login
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.
  • L
    LuciferSam86
    last edited by LuciferSam86 Sep 21, 2017, 3:48 PM Sep 21, 2017, 3:47 PM

    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.

    C 1 Reply Last reply Sep 24, 2017, 1:20 PM Reply Quote 0
    • C
      Claudia Frank @LuciferSam86
      last edited by Sep 24, 2017, 1:20 PM

      @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
      • L
        LuciferSam86
        last edited by Sep 27, 2017, 10:20 AM

        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
        • G
          guy038
          last edited by guy038 Oct 8, 2017, 10:13 PM Oct 8, 2017, 10:13 PM

          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