2

I'm using WinSCP in order to work via SFTP with a remote server running a Linux distro. I'm also using Notepad++ (latest version) as my text editor (when editing a remote file).

When I use WinSCP to create a new file in the remote server using:

Right click > New > File...

Notepad++ opens the empty file, but the encoding appears as ANSI instead of UTF-8 w/o BOM, which is my default. I even have the "Apply to opened ANSI files" option enabled in Notepad++

Settings / Preferences / New Document / Encoding /
   UTF-8 without BOM / Apply to opened ANSI files

Because of this I have to manually select Encoding / Convert to UTF-8 without BOM each time, and if for some reason I forget I have to do that step, well, the file is saved as ANSI and that can cause trouble.

Is there a way for the new file to be encoded as UTF-8 without BOM from the get-go?

  • any solution for this so far? I have the exact same problem. It's annoying having to change the encoding manually each time. – DiegoDD Aug 26 '15 at 21:10
1

Checking Notepad++ source code, I can see that the "Apply to opened ANSI files" option is wrongly labeled. It should read "Apply to opened ASCII files" as it applies to 7-bit (ASCII) files only.

An empty file is "detected" to be 8-bit (ANSI), so the option never applies to empty files.

UniMode um = UnicodeConvertor.getEncoding();
if (um == uni7Bit)
{
    if (ndds._openAnsiAsUtf8)
    {
        um = uniCookie;
    }
    else
    {
        um = uni8Bit;
    }
}

The UnicodeConvertor.getEncoding() always returns uni8Bit when the file is empty.

I suggest you report this as a bug.


Nor there seems to be any command-line option to force different encoding:
http://docs.notepad-plus-plus.org/index.php/Command_Line_Switches

0

This seems to be fixed in Notepad++ 6.4.5 https://notepad-plus-plus.org/download/v6.4.5.html

Fix UTF-8 (w/o BOM) detection bug.

Still, when a new file is created in WinSCP and it is opened with Notepad++, encoding in editors lower right corner is showing ANSI. But when the file is saved, closed, and opened once again, the encoding is UTF8.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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