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

amykonio

Active Member
Licensed User
Longtime 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:
B4X:
myFTP.SendCommand("MKD", parsed(parsed.Length - 1))
Var Parsed is an array of type string.

Is this normal behavior?

Andreas.
 

amykonio

Active Member
Licensed User
Longtime 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.
 
Upvote 0

amykonio

Active Member
Licensed User
Longtime User
@Erel What I did is the following:
B4X:
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:
B4X:
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:
B4X:
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.
 
Upvote 0

amykonio

Active Member
Licensed User
Longtime User
You will need to find out which encoding your FTP server expects. Hopefully your server can properly support non-ascii characters.
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.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…