All pastes #1497433 Raw Edit

WinSCP utf8 autodetect with SFTP

public text v1 · immutable
#1497433 ·published 2009-07-16 20:02 UTC
rendered paste body
--- core/SftpFileSystem.cpp.old	2009-07-16 21:15:39.000000000 +0200
+++ core/SftpFileSystem.cpp	2009-07-16 21:43:34.000000000 +0200
@@ -134,6 +134,7 @@
 #define SFTP_EXT_SPACE_AVAILABLE "space-available"
 #define SFTP_EXT_CHECK_FILE "check-file"
 #define SFTP_EXT_CHECK_FILE_NAME "check-file-name"
+#define SFTP_EXT_UTF8 "utf-8@fazekas.hu"
 //---------------------------------------------------------------------------
 #define OGQ_LIST_OWNERS 0x01
 #define OGQ_LIST_GROUPS 0x02
@@ -2576,6 +2577,8 @@
   FSupport->Loaded = false;
   SAFE_DESTROY(FFixedPaths);
 
+  bool Utf8Hint = false;
+
   if (FVersion >= 3)
   {
     while (Packet.GetNextData() != NULL)
@@ -2721,6 +2724,11 @@
             (ExtensionData)));
         }
       }
+      else if (ExtensionName == SFTP_EXT_UTF8)
+      {
+        FTerminal->LogEvent("Server is using UTF-8 filenames");
+        Utf8Hint = true;
+      }
       else
       {
         FTerminal->LogEvent(FORMAT("Unknown server extension %s=%s",
@@ -2765,7 +2773,7 @@
   FUtfStrings =
     (FTerminal->SessionData->Utf == asOff) ||
     ((FTerminal->SessionData->Utf == asAuto) &&
-      (FVersion >= 4) && !FUtfNever);
+      ((FVersion >= 4) || Utf8Hint) && !FUtfNever);
 
   if (FUtfStrings)
   {