B4J Question [Solved] FTP SendCommand MKD with greek characters on folder name.

Discussion in 'B4J Questions' started by amykonio, Aug 26, 2019.

  1. amykonio

    amykonio Member Licensed User

    Hi.
    I try to use ftp to replicate a structure from a pc to a remote server (I use ftp because there is no other option).
    The problem I'm facing is when I want to create a folder that contains greek characters, the command fails. The message I receive is:
    ReplyCode: 500
    ReplyString:500 'MKD /folder/folder1/??? ??????????? ???????????? ???????- 10.07.2019': command not understood.

    The "?" characters are in place of greek characters...
    The command I use is the following:
    Code:
    myFTP.SendCommand("MKD", parsed(parsed.Length - 1))
    Var Parsed is an array of type string.

    Is this normal behavior?

    Andreas.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    amykonio likes this.
  3. amykonio

    amykonio Member Licensed User

    Thank you Erel…
    Unfortunately I cannot avoid non ascii characters (dir names and file names are defined by third party)...
    After your suggestion It works, but not as I would expect... The dirname created to the remote site is:
    ΡΟΗ ΔΗΜΙΟΥΡΓΙΑΣ ΗΛΕΚΤΡΟΝΙΚΟΥ ΦΑΚΕΛΟΥ- 10.07.2019

    Andreas.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You will need to find out which encoding your FTP server expects. Hopefully your server can properly support non-ascii characters.
     
    OliverA and amykonio like this.
  5. amykonio

    amykonio Member Licensed User

    @Erel What I did is the following:
    Code:
    myFTP.PassiveMode = True
    myFTP.Initialize(
    "myFTP", host, 21, userName, password)
    If Not(myFTP.IsInitialized) Then
       
    Log("Error connecting to FTP!")
       
    Return
    End If
    Dim r As Reflector
    r.Target = myFTP
    r.Target = r.GetField(
    "client")
    r.SetField(
    "_controlEncoding""UTF8""java.lang.String")
    Later I use the SendCommand:
    Code:
    myFTP.SendCommand("MKD", parsed(parsed.Length - 1))
    Wait For (myFTP) myFTP_CommandCompleted (Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
    I also have a CommandCompleted event:
    Code:
    Private Sub myFTP_CommandCompleted (Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
        
    Log(ReplyCode & TAB & ReplyString)
    End Sub
    What is strange is that the ReplyString returns the created folder name correctly with greek characters...
    So only the folder itself has wrong chars.
    Except from client/encoding, is there any other option to allow utf-8 characters in files/folders names? I know some clients (like WinSCP) do have an option for that.

    Andreas.
     
  6. amykonio

    amykonio Member Licensed User

    Based on what I do with other clients I believe it does expect UTF-8. I know that in WinSCP I have to set UTF-8 encoding to filenames to on. Auto and off have issues with Greek...

    Andreas.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    amykonio likes this.
  8. amykonio

    amykonio Member Licensed User

    And well, I was wrong. It is using cp1253... I tested and it works.
    Thank you Erel.

    Andreas.
     
    DonManfred, OliverA and Erel like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice