Ticket #1464: filezilla_utf8.patch

File filezilla_utf8.patch, 28.9 KB (added by tommywu, 19 years ago)

add an option to force to use UTF-8 for remote site

  • CommandQueue.cpp

    diff -Nur source/CommandQueue.cpp source.utf8/CommandQueue.cpp
    old new  
    6868    COptions::SetOption(OPTION_LASTSERVERPORT,server.port);
    6969    COptions::SetOption(OPTION_LASTSERVERUSER,server.user);
    7070    COptions::SetOption(OPTION_LASTSERVERDONTREMEMBERPASS,server.bDontRememberPass?1:0);
     71    COptions::SetOption(OPTION_LASTSERVERUSEUTF8,server.bUTF8?1:0);
    7172    COptions::SetOption(OPTION_LASTSERVERNAME,server.name);
    7273    if (!server.bDontRememberPass && !_ttoi(COptions::GetOption(OPTION_RUNINSECUREMODE)))
    7374        COptions::SetOption(OPTION_LASTSERVERPASS,CCrypt::encrypt(server.pass));
     
    777778        server2.host=COptions::GetOption(OPTION_LASTSERVERHOST);
    778779        server2.port=COptions::GetOptionVal(OPTION_LASTSERVERPORT);
    779780        server2.user=COptions::GetOption(OPTION_LASTSERVERUSER);
     781        server2.bUTF8=COptions::GetOptionVal(OPTION_LASTSERVERUSEUTF8);
    780782        server2.bDontRememberPass=COptions::GetOptionVal(OPTION_LASTSERVERDONTREMEMBERPASS);
    781783        if (!server2.bDontRememberPass)
    782784        {
  • FileZilla.rc

    diff -Nur source/FileZilla.rc source.utf8/FileZilla.rc
    old new  
    955955                    IDC_STATIC,14,156,141,8
    956956END
    957957
    958 IDD_SITEMANAGER_ADVANCED DIALOGEX 0, 0, 240, 177
     958IDD_SITEMANAGER_ADVANCED DIALOGEX 0, 0, 240, 193
    959959STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    960960CAPTION "Advanced Site settings"
    961961FONT 8, "MS Shell Dlg", 0, 0, 0x1
     
    977977                    UDS_ARROWKEYS | UDS_NOTHOUSANDS,103,127,11,14
    978978    LTEXT           "Adjust remote file time by",IDC_STATIC,7,131,78,8
    979979    LTEXT           "hours",IDC_STATIC,119,131,18,8
    980     PUSHBUTTON      "OK",IDOK,55,156,50,14
    981     PUSHBUTTON      "Cancel",IDCANCEL,135,156,50,14
     980    PUSHBUTTON      "OK",IDOK,55,172,50,14
     981    PUSHBUTTON      "Cancel",IDCANCEL,135,172,50,14
    982982    LTEXT           "Default &local directory:",IDC_STATIC,7,28,71,8
    983983    EDITTEXT        IDC_LOCALDIR,7,36,142,14,ES_AUTOHSCROLL
    984984    PUSHBUTTON      "...",IDC_SITEMANAGER_LOCALDIR_BROWSE,153,36,12,14
     
    991991    LTEXT           "Default remote d&irectory:",IDC_STATIC,7,58,78,8
    992992    EDITTEXT        IDC_REMOTEDIR,7,66,157,14,ES_AUTOHSCROLL,
    993993                    WS_EX_TRANSPARENT
     994    CONTROL         "Use UTF-&8 for remote",IDC_CHECK_USEUTF8,"Button",
     995                    BS_AUTOCHECKBOX | WS_TABSTOP,7,153,85,10
    994996END
    995997
    996998IDD_OPTIONS_PANELAYOUT DIALOGEX 0, 0, 286, 217
  • FtpControlSocket.cpp

    diff -Nur source/FtpControlSocket.cpp source.utf8/FtpControlSocket.cpp
    old new  
    242242            filename = "cacert.pem";
    243243    }
    244244
     245    m_bUTF8 = server.bUTF8;
     246
    245247    if (!server.fwbypass)
    246248    {
    247249        int nProxyType = COptions::GetOptionVal(OPTION_PROXYTYPE);
  • FzApiStructures.h

    diff -Nur source/FzApiStructures.h source.utf8/FzApiStructures.h
    old new  
    3232    int port;
    3333    CString user,pass;
    3434    BOOL fwbypass;
     35    BOOL bUTF8;
    3536    CString path;
    3637    BOOL bDontRememberPass;
    3738    int nServerType;
  • FzSFtp/PSFTP.C

    diff -Nur source/FzSFtp/PSFTP.C source.utf8/FzSFtp/PSFTP.C
    old new  
    1717#include "int64.h"
    1818
    1919#include "FzSFtpIpc.h"
     20#include <tchar.h>
    2021
    2122/*
    2223 * Since SFTP is a request-response oriented protocol, it requires
     
    389390    sfree(fname);
    390391    return 0;
    391392    }
    392 
     393#ifdef _UNICODE
     394    {
     395        int len;
     396
     397        // convert from UTF-8 to ANSI
     398        len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)outfname, -1, NULL, 0);
     399        if (len != 0)
     400        {
     401            wchar_t *p1;
     402
     403            p1 = malloc(sizeof(wchar_t) * (len*2+1));
     404            MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)outfname, -1 , (LPWSTR)p1, len*2);
     405            if (restart)
     406            fp = CreateFile(p1, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
     407            else
     408            fp = CreateFile(p1, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
     409            free(p1);
     410        }
     411        else {
     412            if (restart)
     413            fp = CreateFileA(outfname, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
     414            else
     415            fp = CreateFileA(outfname, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
     416        }
     417    }
     418#else
    393419    if (restart)
    394420    fp = CreateFileA(outfname, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
    395421    else
    396422    fp = CreateFileA(outfname, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
    397 
     423#endif
    398424    if (fp==INVALID_HANDLE_VALUE)
    399425    {
    400426    FzSFtpIpc_Error1("Unable to open %s", outfname);
     
    508534    return 0;
    509535    }
    510536
     537#ifdef _UNICODE
     538    {
     539        int len;
     540
     541        // convert from UTF-8 to ANSI
     542        len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)localfile, -1, NULL, 0);
     543        if (len != 0)
     544        {
     545            wchar_t *p1;
     546
     547            p1 = malloc(sizeof(wchar_t) * (len*2+1));
     548            MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)localfile, -1 , (LPWSTR)p1, len*2);
     549            fp = CreateFile(p1, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
     550            free(p1);
     551        }
     552        else {
     553            fp = CreateFileA(localfile, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
     554        }
     555    }
     556#else
    511557    fp = CreateFileA(localfile, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
     558#endif
    512559    if (fp == INVALID_HANDLE_VALUE)
    513560    {
    514561    FzSFtpIpc_Error1("Unable to open %s", localfile);
  • MainFrm.cpp

    diff -Nur source/MainFrm.cpp source.utf8/MainFrm.cpp
    old new  
    39983998    server.path=site.RemoteDir;
    39993999    server.fwbypass=site.bFirewallBypass;
    40004000    server.bDontRememberPass=site.bPassDontSave;
     4001    server.bUTF8 = site.bUTF8;
    40014002    server.name = site.name;
    40024003    server.nPasv = site.nPasv;
    40034004    server.nTimeZoneOffset = site.nTimeZoneOffset * 60 + site.nTimeZoneOffset2;
     
    44144415    server.port=_ttoi(m_Port);
    44154416    server.path=path;
    44164417    server.fwbypass=bBypass;
     4418    server.bUTF8=FALSE;
    44174419    server.bDontRememberPass=FALSE;
    44184420    m_pCommandQueue->Connect(server);
    44194421    if (path!="")
  • Options.cpp

    diff -Nur source/Options.cpp source.utf8/Options.cpp
    old new  
    507507                                    _T("Switch view locations"),        1,  _T("Use MODE Z "),                      1,
    508508                                    _T("MODE Z level"),                 1,  _T("Transfer IP v6"),                   0,
    509509                                    _T("Enable IPv6"),                  1,  _T("Log Timestamps"),                   1,
    510                                     _T("VMS display all revisions"),    1
     510                                    _T("VMS display all revisions"),    1,  _T("Last Server UseUTF8"),              1
    511511                                };
    512512
    513513void COptions::SetOption(int nOptionID,int value)
  • Options.h

    diff -Nur source/Options.h source.utf8/Options.h
    old new  
    5252
    5353#include "misc\MarkupSTL.h"
    5454
    55 #define OPTIONS_NUM 115
     55#define OPTIONS_NUM 116
    5656
    5757/////////////////////////////////////////////////////////////////////////////
    5858// Dialogfeld COptions
     
    280280#define OPTION_ENABLE_IPV6 113
    281281#define OPTION_LOGTIMESTAMPS 114
    282282#define OPTION_VMSALLREVISIONS 115
     283#define OPTION_LASTSERVERUSEUTF8 116
    283284
    284285//{{AFX_INSERT_LOCATION}}
    285286// Microsoft Visual C++ fügt unmittelbar vor der vorhergehenden Zeile zusätzliche Deklarationen ein.
  • SFtpIpc.cpp

    diff -Nur source/SFtpIpc.cpp source.utf8/SFtpIpc.cpp
    old new  
    146146
    147147    m_hReceiveThread=0;
    148148    m_hExitEvent=0;
     149    m_bUTF8 = pOwner->m_bUTF8;
    149150}
    150151
    151152CSFtpIpc::~CSFtpIpc()
     
    417418BOOL CSFtpIpc::Send(const DWORD &nID, LPCTSTR str)
    418419{
    419420    USES_CONVERSION;
    420     if (str)
    421         return Send(nID, (const DWORD)strlen(T2CA(str))+1, (LPVOID)T2CA(str));
     421
     422    if (str) {
     423        if (m_bUTF8)
     424        {
     425            bool res;
     426            LPCWSTR unicode = T2CW(str);
     427            int len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, 0, 0, 0, 0);
     428            char* utf8 = new char[len + 1];
     429            WideCharToMultiByte(CP_UTF8, 0, unicode, -1, utf8, len + 1, 0, 0);
     430
     431            res = Send(nID, (const DWORD)strlen(utf8)+1, (LPVOID)utf8);
     432            delete [] utf8;
     433            return res;
     434        }
     435        else
     436        {
     437            return Send(nID, (const DWORD)strlen(T2CA(str))+1, (LPVOID)T2CA(str));
     438        }
     439    }
    422440    else
    423441        return Send(nID, 0, 0);
    424442}
  • SFtpIpc.h

    diff -Nur source/SFtpIpc.h source.utf8/SFtpIpc.h
    old new  
    6464    HANDLE m_hReceiveThread;
    6565    static DWORD WINAPI ReceiveThread( LPVOID pParam );
    6666    HANDLE m_hExitEvent;
     67    bool m_bUTF8;
    6768};
    6869
    6970#endif // !defined(AFX_SFTPIPC_H__71B20B86_C3D8_4197_90C2_349A18548D58__INCLUDED_)
  • SftpControlSocket.cpp

    diff -Nur source/SftpControlSocket.cpp source.utf8/SftpControlSocket.cpp
    old new  
    3939class CSFtpControlSocket::CFileTransferData : public CSFtpControlSocket::t_operation::COpData
    4040{
    4141public:
    42     CFileTransferData(t_server server)
     42    CFileTransferData(t_server server, bool bUTF8)
    4343    {
    4444        pDirectoryListing=0;
    4545        nWaitNextOpState=0;
     
    5050        transferdata.nTransferStart=0;
    5151        pStartTime=0;
    5252        bUseAbsolutePaths = FALSE;
    53         pParser = new CFtpListResult(server);
     53        pParser = new CFtpListResult(server, bUTF8);
    5454    };
    5555    virtual ~CFileTransferData()
    5656    {
     
    7979class CSFtpControlSocket::CListData:public CSFtpControlSocket::t_operation::COpData
    8080{
    8181public:
    82     CListData(t_server server)
     82    CListData(t_server server, bool bUTF8)
    8383    {
    8484        pDirectoryListing=0;
    85         pParser = new CFtpListResult(server);
     85        pParser = new CFtpListResult(server, bUTF8);
    8686    }
    8787    virtual ~CListData()
    8888    {
     
    124124    m_bQuit=FALSE;
    125125    m_bCheckForTimeout=TRUE;
    126126    m_bError=FALSE;
     127    m_bUTF8 = false;
    127128}
    128129
    129130CSFtpControlSocket::~CSFtpControlSocket()
     
    154155    ASSERT(!m_Operation.nOpMode);
    155156   
    156157    ASSERT(!m_pProxyLayer);
     158
     159    m_bUTF8 = server.bUTF8;
    157160   
    158161    if (!server.fwbypass)
    159162    {
     
    326329        if (m_Operation.nOpState==LIST_PWD)
    327330        { //Reply to PWD command
    328331            pData->realpath.SetServer(m_CurrentServer);
    329             if (m_Reply=="" || !pData->realpath.SetPath(A2CT(m_Reply)))
    330             {
    331                 LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
    332                 ResetOperation(FZ_REPLY_ERROR);
    333                 return;
     332            if (m_bUTF8) {
     333                USES_CONVERSION;
     334
     335                // convert from UTF-8 to ANSI
     336                int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)m_Reply, -1, NULL, 0);
     337                if (len != 0)
     338                {
     339                    LPWSTR p1 = new WCHAR[len + 1];
     340                    MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)m_Reply, -1 , (LPWSTR)p1, len*2);
     341                    CString tempstr = W2CT(p1);
     342                    delete [] p1;
     343                    if (tempstr=="" || !pData->realpath.SetPath(tempstr))
     344                    {
     345                        LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
     346                        ResetOperation(FZ_REPLY_ERROR);
     347                        return;
     348                    }
     349                    pData->rawpwd=tempstr;
     350                }
     351                else
     352                {
     353                    LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
     354                    ResetOperation(FZ_REPLY_ERROR);
     355                    return;
     356                }
     357            }
     358            else {
     359                if (m_Reply=="" || !pData->realpath.SetPath(A2CT(m_Reply)))
     360                {
     361                    LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
     362                    ResetOperation(FZ_REPLY_ERROR);
     363                    return;
     364                }
     365                pData->rawpwd=m_Reply;
    334366            }
    335             pData->rawpwd=m_Reply;
    336367            m_pOwner->SetCurrentPath(pData->realpath);
    337368            if (pData->nListMode&FZ_LIST_USECACHE)
    338369            {
     
    363394        else if (m_Operation.nOpState==LIST_CWD)
    364395        {
    365396            pData->realpath.SetServer(m_CurrentServer);
    366             if (m_Reply=="" || !pData->realpath.SetPath(A2CT(m_Reply)))
    367             {
    368                 LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
    369                 ResetOperation(FZ_REPLY_ERROR);
    370                 return;
     397            if (m_bUTF8) {
     398                USES_CONVERSION;
     399
     400                // convert from UTF-8 to ANSI
     401                int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)m_Reply, -1, NULL, 0);
     402                if (len != 0)
     403                {
     404                    LPWSTR p1 = new WCHAR[len + 1];
     405                    MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)m_Reply, -1 , (LPWSTR)p1, len*2);
     406                    CString tempstr = W2CT(p1);
     407                    delete [] p1;
     408                    if (tempstr=="" || !pData->realpath.SetPath(tempstr))
     409                    {
     410                        LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
     411                        ResetOperation(FZ_REPLY_ERROR);
     412                        return;
     413                    }
     414                    pData->rawpwd=tempstr;
     415                }
     416                else
     417                {
     418                    LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
     419                    ResetOperation(FZ_REPLY_ERROR);
     420                    return;
     421                }
     422            }
     423            else {
     424                if (m_Reply=="" || !pData->realpath.SetPath(A2CT(m_Reply)))
     425                {
     426                    LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
     427                    ResetOperation(FZ_REPLY_ERROR);
     428                    return;
     429                }
     430                pData->rawpwd=m_Reply;
    371431            }
    372             pData->rawpwd=m_Reply;
    373432            m_pOwner->SetCurrentPath(pData->realpath);
    374433            if (pData->nListMode&FZ_LIST_USECACHE && pData->subdir=="")
    375434            {
     
    410469        else if (m_Operation.nOpState==LIST_CWD2)
    411470        {
    412471            pData->realpath.SetServer(m_CurrentServer);
    413             if (m_Reply=="" || !pData->realpath.SetPath(A2CT(m_Reply)))
    414             {
    415                 LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
    416                 ResetOperation(FZ_REPLY_ERROR);
    417                 return;
     472            if (m_bUTF8) {
     473                USES_CONVERSION;
     474
     475                // convert from UTF-8 to ANSI
     476                int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)m_Reply, -1, NULL, 0);
     477                if (len != 0)
     478                {
     479                    LPWSTR p1 = new WCHAR[len + 1];
     480                    MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)m_Reply, -1 , (LPWSTR)p1, len*2);
     481                    CString tempstr = W2CT(p1);
     482                    delete [] p1;
     483                    if (tempstr=="" || !pData->realpath.SetPath(tempstr))
     484                    {
     485                        LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
     486                        ResetOperation(FZ_REPLY_ERROR);
     487                        return;
     488                    }
     489                    pData->rawpwd=tempstr;
     490                }
     491                else
     492                {
     493                    LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
     494                    ResetOperation(FZ_REPLY_ERROR);
     495                    return;
     496                }
     497            }
     498            else {
     499                if (m_Reply=="" || !pData->realpath.SetPath(A2CT(m_Reply)))
     500                {
     501                    LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path") );
     502                    ResetOperation(FZ_REPLY_ERROR);
     503                    return;
     504                }
     505                pData->rawpwd=m_Reply;
    418506            }
    419             pData->rawpwd=m_Reply;
    420507            m_pOwner->SetCurrentPath(pData->realpath);
    421508            if (pData->nListMode&FZ_LIST_USECACHE)
    422509            {
     
    512599   
    513600    if (m_Operation.nOpState==LIST_INIT)
    514601    { //Initialize some variables
    515         pData = new CListData(m_CurrentServer);;
     602        pData = new CListData(m_CurrentServer, m_bUTF8);
    516603        pData->nListMode=nListMode;
    517604        pData->path=path;
    518605        pData->subdir=subdir;
     
    691778       
    692779        m_Operation.nOpMode=CSMODE_TRANSFER|(transferfile->get?CSMODE_DOWNLOAD:CSMODE_UPLOAD);
    693780
    694         pData = new CFileTransferData(m_CurrentServer);
     781        pData = new CFileTransferData(m_CurrentServer, m_bUTF8);
    695782        m_Operation.pData=pData;
    696783
    697784        //Replace invalid characters in the local filename
     
    821908            {
    822909                CServerPath path;
    823910                path.SetServer(m_CurrentServer);
    824                 if (!path.SetPath(A2CT(m_Reply)))
     911                CString tempstr;
     912                if (m_bUTF8) {
     913                    USES_CONVERSION;
     914
     915                    // convert from UTF-8 to ANSI
     916                    int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)m_Reply, -1, NULL, 0);
     917                    if (len != 0)
     918                    {
     919                        LPWSTR p1 = new WCHAR[len + 1];
     920                        MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)m_Reply, -1 , (LPWSTR)p1, len*2);
     921                        tempstr = W2CT(p1);
     922                        delete [] p1;
     923                    }
     924                    else
     925                    {
     926                        tempstr = "";
     927                    }
     928                }
     929                else {
     930                    tempstr = A2CT(m_Reply);
     931                }
     932                if (!path.SetPath(tempstr))
    825933                {
    826934                    LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path"));
    827935                    nReplyError=FZ_REPLY_ERROR;
    828936                }
    829937                else
    830938                {
    831                     pData->rawpwd=m_Reply;
     939                    pData->rawpwd=tempstr;
    832940                    m_pOwner->SetCurrentPath(path);
    833941                    if (path!=pData->transferfile.remotepath)
    834942                        nReplyError=FZ_REPLY_ERROR | FZ_REPLY_CRITICALERROR;
     
    10461154            {
    10471155                CServerPath path;
    10481156                path.SetServer(m_CurrentServer);
    1049                 if (!path.SetPath(A2CT(m_Reply)))
     1157                CString tempstr;
     1158                if (m_bUTF8) {
     1159                    USES_CONVERSION;
     1160
     1161                    // convert from UTF-8 to ANSI
     1162                    int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)m_Reply, -1, NULL, 0);
     1163                    if (len != 0)
     1164                    {
     1165                        LPWSTR p1 = new WCHAR[len + 1];
     1166                        MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)m_Reply, -1 , (LPWSTR)p1, len*2);
     1167                        tempstr = W2CT(p1);
     1168                        delete [] p1;
     1169                    }
     1170                    else
     1171                    {
     1172                        tempstr = "";
     1173                    }
     1174                }
     1175                else {
     1176                    tempstr = A2CT(m_Reply);
     1177                }
     1178                if (!path.SetPath(tempstr))
    10501179                {
    10511180                    LogMessage(__FILE__, __LINE__, this,FZ_LOG_WARNING, _T("Can't parse path"));
    10521181                    nReplyError=FZ_REPLY_ERROR;
    10531182                }
    10541183                else
    10551184                {
    1056                     pData->rawpwd=m_Reply;
     1185                    pData->rawpwd=tempstr;
    10571186                    m_pOwner->SetCurrentPath(path);
    10581187                    if (path!=pData->transferfile.remotepath)
    10591188                        nReplyError=FZ_REPLY_ERROR | FZ_REPLY_CRITICALERROR;
     
    13361465            filename = pData->transferfile.remotefile;
    13371466        else
    13381467            filename = pData->transferfile.remotepath.GetPath() + pData->transferfile.remotefile;
    1339         int nLen1=strlen(T2CA(filename)) + 1;
    1340         int nLen2=strlen(T2CA(pData->transferfile.localfile))+1;
    1341         char *pCmd=new char[nLen1+nLen2+4];
    1342         strcpy(pCmd, T2CA(filename));
    1343         strcpy(pCmd+nLen1, T2CA(pData->transferfile.localfile));
    1344         memcpy(pCmd+nLen1+nLen2, &pData->transferdata.bResume, 4);
     1468        char *pCmd;
     1469        int nLen1;
     1470        int nLen2;
     1471        if (m_bUTF8) {
     1472#ifdef _UNICODE
     1473            LPCWSTR unicode_remote = T2CW(filename);
     1474            int len = WideCharToMultiByte(CP_UTF8, 0, unicode_remote, -1, 0, 0, 0, 0);
     1475            char* utf8_remote = new char[len + 1];
     1476            WideCharToMultiByte(CP_UTF8, 0, unicode_remote, -1, utf8_remote, len + 1, 0, 0);
     1477            LPCWSTR unicode_local = T2CW(pData->transferfile.localfile);
     1478            len = WideCharToMultiByte(CP_UTF8, 0, unicode_local, -1, 0, 0, 0, 0);
     1479            char* utf8_local = new char[len + 1];
     1480            WideCharToMultiByte(CP_UTF8, 0, unicode_local, -1, utf8_local, len + 1, 0, 0);
     1481            nLen1=strlen(utf8_remote) + 1;
     1482            nLen2=strlen(utf8_local)+1;
     1483            pCmd=new char[nLen1+nLen2+4];
     1484            strcpy(pCmd, utf8_remote);
     1485            delete [] utf8_remote;
     1486            strcpy(pCmd+nLen1, utf8_local);
     1487            delete [] utf8_local;
     1488            memcpy(pCmd+nLen1+nLen2, &pData->transferdata.bResume, 4);
     1489#else
     1490            LPCWSTR unicode_remote = T2CW(filename);
     1491            int len = WideCharToMultiByte(CP_UTF8, 0, unicode_remote, -1, 0, 0, 0, 0);
     1492            char* utf8_remote = new char[len + 1];
     1493            WideCharToMultiByte(CP_UTF8, 0, unicode_remote, -1, utf8_remote, len + 1, 0, 0);
     1494            nLen1=strlen(utf8_remote) + 1;
     1495            nLen2=strlen(T2CA(pData->transferfile.localfile))+1;
     1496            pCmd=new char[nLen1+nLen2+4];
     1497            strcpy(pCmd, utf8_remote);
     1498            delete [] utf8_remote;
     1499            strcpy(pCmd+nLen1, T2CA(pData->transferfile.localfile));
     1500            memcpy(pCmd+nLen1+nLen2, &pData->transferdata.bResume, 4);
     1501#endif
     1502        }
     1503        else {
     1504#ifdef _UNICODE
     1505            LPCWSTR unicode_local = T2CW(pData->transferfile.localfile);
     1506            int len = WideCharToMultiByte(CP_UTF8, 0, unicode_local, -1, 0, 0, 0, 0);
     1507            char* utf8_local = new char[len + 1];
     1508            WideCharToMultiByte(CP_UTF8, 0, unicode_local, -1, utf8_local, len + 1, 0, 0);
     1509            nLen1=strlen(T2CA(filename)) + 1;
     1510            nLen2=strlen(utf8_local)+1;
     1511            pCmd=new char[nLen1+nLen2+4];
     1512            strcpy(pCmd, T2CA(filename));
     1513            strcpy(pCmd+nLen1, utf8_local);
     1514            delete [] utf8_local;
     1515            memcpy(pCmd+nLen1+nLen2, &pData->transferdata.bResume, 4);
     1516#else
     1517            nLen1=strlen(T2CA(filename)) + 1;
     1518            nLen2=strlen(T2CA(pData->transferfile.localfile))+1;
     1519            pCmd=new char[nLen1+nLen2+4];
     1520            strcpy(pCmd, T2CA(filename));
     1521            strcpy(pCmd+nLen1, T2CA(pData->transferfile.localfile));
     1522            memcpy(pCmd+nLen1+nLen2, &pData->transferdata.bResume, 4);
     1523#endif
     1524        }
    13451525        pData->pStartTime = new CTime;
    13461526        *pData->pStartTime = CTime::GetCurrentTime();
    13471527        if (pData->transferfile.get)
     
    15081688        char *pData;
    15091689        if (newPath.IsEmpty())
    15101690        {
    1511             nLen = _tcslen( path.GetPath() + oldName + path.GetPath() + newName) + 2;
    1512             pData = new char[nLen];
    1513             strcpy(pData, T2CA(path.GetPath() + oldName));
    1514             strcpy(pData + _tcslen(path.GetPath() + oldName) + 1, T2CA(path.GetPath() + newName));
     1691            if (m_bUTF8) {
     1692                LPCWSTR uni_oldname = T2CW(path.GetPath() + oldName);
     1693                int len = WideCharToMultiByte(CP_UTF8, 0, uni_oldname, -1, 0, 0, 0, 0);
     1694                char* utf8_oldname = new char[len + 1];
     1695                WideCharToMultiByte(CP_UTF8, 0, uni_oldname, -1, utf8_oldname, len + 1, 0, 0);
     1696                LPCWSTR uni_newname = T2CW(path.GetPath() + newName);
     1697                len = WideCharToMultiByte(CP_UTF8, 0, uni_newname, -1, 0, 0, 0, 0);
     1698                char* utf8_newname = new char[len + 1];
     1699                WideCharToMultiByte(CP_UTF8, 0, uni_newname, -1, utf8_newname, len + 1, 0, 0);
     1700                nLen = strlen(utf8_oldname) + strlen(utf8_newname) + 2;
     1701                pData = new char[nLen];
     1702                strcpy(pData, utf8_oldname);
     1703                strcpy(pData + strlen(utf8_oldname) + 1, utf8_newname);
     1704                delete [] utf8_oldname;
     1705                delete [] utf8_newname;
     1706            }
     1707            else {
     1708                nLen = _tcslen( path.GetPath() + oldName + path.GetPath() + newName) + 2;
     1709                pData = new char[nLen];
     1710                strcpy(pData, T2CA(path.GetPath() + oldName));
     1711                strcpy(pData + _tcslen(path.GetPath() + oldName) + 1, T2CA(path.GetPath() + newName));
     1712            }
    15151713        }
    15161714        else
    15171715        {
    1518             nLen = _tcslen( path.GetPath() + oldName + newPath.GetPath() + newName) + 2;
    1519             pData = new char[nLen];
    1520             strcpy(pData, T2CA(path.GetPath() + oldName));
    1521             strcpy(pData + _tcslen(path.GetPath() + oldName) + 1, T2CA(newPath.GetPath() + newName));
     1716            if (m_bUTF8) {
     1717                LPCWSTR uni_oldname = T2CW(path.GetPath() + oldName);
     1718                int len = WideCharToMultiByte(CP_UTF8, 0, uni_oldname, -1, 0, 0, 0, 0);
     1719                char* utf8_oldname = new char[len + 1];
     1720                WideCharToMultiByte(CP_UTF8, 0, uni_oldname, -1, utf8_oldname, len + 1, 0, 0);
     1721                LPCWSTR uni_newname = T2CW(newPath.GetPath() + newName);
     1722                len = WideCharToMultiByte(CP_UTF8, 0, uni_newname, -1, 0, 0, 0, 0);
     1723                char* utf8_newname = new char[len + 1];
     1724                WideCharToMultiByte(CP_UTF8, 0, uni_newname, -1, utf8_newname, len + 1, 0, 0);
     1725                nLen = strlen(utf8_oldname) + strlen(utf8_newname) + 2;
     1726                pData = new char[nLen];
     1727                strcpy(pData, utf8_oldname);
     1728                strcpy(pData + strlen(utf8_oldname) + 1, utf8_newname);
     1729                delete [] utf8_oldname;
     1730                delete [] utf8_newname;
     1731            }
     1732            else {
     1733                nLen = _tcslen( path.GetPath() + oldName + newPath.GetPath() + newName) + 2;
     1734                pData = new char[nLen];
     1735                strcpy(pData, T2CA(path.GetPath() + oldName));
     1736                strcpy(pData + _tcslen(path.GetPath() + oldName) + 1, T2CA(newPath.GetPath() + newName));
     1737            }
    15221738        }
    15231739        if (!m_pDataChannel->Send(SFTP_DATAID_STC_RENAME, nLen, pData))
    15241740        {
     
    29213137    USES_CONVERSION;
    29223138    m_Operation.nOpMode=CSMODE_CHMOD;
    29233139    CString str;
     3140    int nLen;
     3141    char *pData;
    29243142    str.Format( _T("%d %s%s"), nValue, path.GetPath(), filename);
    2925     int nLen=strlen(T2CA(str))+1;
    2926     char *pData=new char[nLen];
    2927     strcpy(pData, T2CA(str));
    2928     int pos(str.Find( _T(" ") ));
    2929     ASSERT(pos!=-1);
    2930     pData[pos]=0;
     3143    if (m_bUTF8) {
     3144        USES_CONVERSION;
     3145
     3146        LPCWSTR unicode = T2CW(str);
     3147        int len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, 0, 0, 0, 0);
     3148        char* utf8 = new char[len + 1];
     3149        WideCharToMultiByte(CP_UTF8, 0, unicode, -1, utf8, len + 1, 0, 0);
     3150        nLen=strlen(utf8)+1;
     3151        pData=new char[nLen];
     3152        strcpy(pData, utf8);
     3153        int pos(str.Find( _T(" ") ));
     3154        ASSERT(pos!=-1);
     3155        pData[pos]=0;
     3156    }
     3157    else {
     3158        nLen=strlen(T2CA(str))+1;
     3159        pData=new char[nLen];
     3160        strcpy(pData, T2CA(str));
     3161        int pos(str.Find( _T(" ") ));
     3162        ASSERT(pos!=-1);
     3163        pData[pos]=0;
     3164    }
    29313165    if (!m_pDataChannel->Send(SFTP_DATAID_STC_CHMOD, nLen, pData))
    29323166        DoClose();
    29333167    delete [] pData;
  • SftpControlSocket.h

    diff -Nur source/SftpControlSocket.h source.utf8/SftpControlSocket.h
    old new  
    3737class CSFtpControlSocket : public CControlSocket
    3838{
    3939public:
     40    bool m_bUTF8;
    4041    BOOL m_bError;
    4142    void OnClientError(int nErrorCode);
    4243    int OnClientRequest(int nId, int &nDataLength, LPVOID pData);
  • SiteManager.cpp

    diff -Nur source/SiteManager.cpp source.utf8/SiteManager.cpp
    old new  
    646646    site->nLogonType = _ttoi(GetKey(hRootKey, Name, "Logontype"))-1;
    647647    site->RemoteDir = GetKey(hRootKey, Name, "Remote Dir");
    648648    site->LocalDir = GetKey(hRootKey, Name, "Local Dir");
     649    site->bUTF8 = _ttoi(GetKey(hRootKey, Name, "Use UTF8"));
    649650    site->bFirewallBypass = _ttoi(GetKey(hRootKey, Name, "FW Bypass"));
    650651    site->bPassDontSave = _ttoi(GetKey(hRootKey, Name, "Dont Save Pass"));
    651652    site->nServerType = _ttoi(GetKey(hRootKey, Name, "Server Type"));
     
    676677    site->nLogonType = _ttoi(pMarkup->GetChildAttrib( _T("Logontype") ));
    677678    site->RemoteDir = pMarkup->GetChildAttrib( _T("RemoteDir") );
    678679    site->LocalDir = pMarkup->GetChildAttrib( _T("LocalDir") );
     680    site->bUTF8 = _ttoi(pMarkup->GetChildAttrib( _T("UseUTF8") ));
    679681    site->bFirewallBypass = _ttoi(pMarkup->GetChildAttrib( _T("FWBypass") ));
    680682    site->bPassDontSave = _ttoi(pMarkup->GetChildAttrib( _T("DontSavePass") ));
    681683    site->nServerType = _ttoi(pMarkup->GetChildAttrib( _T("ServerType") ));
     
    13791381                    startsWith(str, _T("Default remote dir: ")) ||
    13801382                    startsWith(str, _T("Default remote folder: ")))
    13811383                    pSite->RemoteDir = str;
     1384                else if (startsWith(str, _T("Use UTF8: ")))
     1385                    pSite->bUTF8 = _ttoi(str);
    13821386                else if (startsWith(str, _T("Firewall Bypass: ")))
    13831387                    pSite->bFirewallBypass = _ttoi(str);
    13841388                else if (startsWith(str, _T("Dont Save Pass: ")))
     
    16941698        SetKey(name, _T("Pass"), _T(""));
    16951699    else
    16961700        SetKey(name, "Pass", CCrypt::encrypt(site->Pass));
     1701    str=site->bUTF8?"1":"0";
     1702    SetKey(name,"Use UTF8",str);
    16971703    str.Format(_T("%d"), site->nLogonType+1);
    16981704    SetKey(name,"Logontype",str);
    16991705    str=site->bFirewallBypass?"1":"0";
     
    17181724    pMarkup->AddChildAttrib( _T("User"), site->User);
    17191725    pMarkup->AddChildAttrib( _T("RemoteDir"), site->RemoteDir);
    17201726    pMarkup->AddChildAttrib( _T("LocalDir"), site->LocalDir);
     1727    pMarkup->AddChildAttrib( _T("UseUTF8"), site->bUTF8);
    17211728    if (_ttoi(COptions::GetOption(OPTION_RUNINSECUREMODE)) || site->bPassDontSave)
    17221729        pMarkup->AddChildAttrib( _T("Pass"), _T(""));
    17231730    else
  • SiteManager.h

    diff -Nur source/SiteManager.h source.utf8/SiteManager.h
    old new  
    4242    CString Pass;
    4343    CString RemoteDir;
    4444    CString LocalDir;
     45    BOOL bUTF8;
    4546    int nLogonType;
    4647    BOOL bFirewallBypass;
    4748    BOOL bPassDontSave;
  • SiteManagerAdvancedDlg.cpp

    diff -Nur source/SiteManagerAdvancedDlg.cpp source.utf8/SiteManagerAdvancedDlg.cpp
    old new  
    2828    m_nPassive = -1;
    2929    m_LocalDir = _T("");
    3030    m_RemoteDir = _T("");
     31    m_bUTF8 = false;
    3132    //}}AFX_DATA_INIT
    3233}
    3334
     
    4546    DDX_Radio(pDX, IDC_SITEMANAGER_ADVANCED_PASSIVE1, m_nPassive);
    4647    DDX_Text(pDX, IDC_LOCALDIR, m_LocalDir);
    4748    DDX_Text(pDX, IDC_REMOTEDIR, m_RemoteDir);
     49    DDX_Check(pDX, IDC_CHECK_USEUTF8, m_bUTF8);
    4850    //}}AFX_DATA_MAP
    4951}
    5052
     
    8082
    8183    m_LocalDir = m_pSiteManagerItem->LocalDir;
    8284    m_RemoteDir = m_pSiteManagerItem->RemoteDir;
     85    m_bUTF8 = m_pSiteManagerItem->bUTF8;
    8386
    8487    UpdateData(FALSE);
    8588   
     
    105108        m_RemoteDir = path.GetPath();
    106109    }
    107110   
     111    m_pSiteManagerItem->bUTF8 = m_bUTF8;
    108112    m_pSiteManagerItem->LocalDir = m_LocalDir;
    109113    m_pSiteManagerItem->RemoteDir = m_RemoteDir;
    110114    m_pSiteManagerItem->nPasv = m_nPassive;
  • SiteManagerAdvancedDlg.h

    diff -Nur source/SiteManagerAdvancedDlg.h source.utf8/SiteManagerAdvancedDlg.h
    old new  
    2929    int     m_nPassive;
    3030    CString m_LocalDir;
    3131    CString m_RemoteDir;
     32    BOOL    m_bUTF8;
    3233    //}}AFX_DATA
    3334
    3435
  • resource.h

    diff -Nur source/resource.h source.utf8/resource.h
    old new  
    349349#define IDC_OPTIONS_TRANSFER_COMPRESSION_LEVEL 1284
    350350#define IDC_OPTIONS_TRANSFER_COMPRESSION_FILETYPES 1285
    351351#define IDC_OPTIONS_CONNECTION2_ENABLEIPV6 1287
     352#define IDC_CHECK_USEUTF8               1288
    352353#define IDS_STATUSMSG_CONNECTED         2000
    353354#define IDS_STATUSMSG_CONNECTEDWITH     2001
    354355#define IDS_STATUSMSG_CONNECTEDWITHSFTP 2002
     
    756757#define _APS_3D_CONTROLS                     1
    757758#define _APS_NEXT_RESOURCE_VALUE        3105
    758759#define _APS_NEXT_COMMAND_VALUE         32902
    759 #define _APS_NEXT_CONTROL_VALUE         1288
     760#define _APS_NEXT_CONTROL_VALUE         1289
    760761#define _APS_NEXT_SYMED_VALUE           3205
    761762#endif
    762763#endif