Android Question FTP file names, non-ASCII

peacemaker

Expert
Licensed User
Longtime User

MarcoRome

Expert
Licensed User
Longtime User
Try
su.EncodeUrl(namefileinrussian.jpg, "uft8")

so...
B4X:
FTP.DownloadFile(  "/hotel/"&su.EncodeUrl("выакекем.jpg", "uft8"), False, File.DirRootExternal, "test.jpg")
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
B4X:
        Dim r As Reflector
        r.Target = FTP1
        r.Target = r.GetField("client")
        r.SetField("_controlEncoding", "UTF8", "java.lang.String")

This code just modifies file names into:
B4X:
f.Name=preview_���� � ��� ��������.jpg
f.Name=preview_���� � ���.jpg
f.Name=preview_������� �������.jpg
f.Name=preview_������������.jpg
But this should be used before the connection, but it's impossible, we have only Init method.
So, no use.

And "OPTS UTF8 ON" command is unknown on this FTP server....
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
B4X:
Connect to: (06.03.2017 11:05:40)
hostname=77.222.XXX.XXX
username=username123
startdir=
77.222.XXX.XXX=77.222.XXX.XXX
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 5 of 100 allowed.
220-Local time is now 10:05. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
USER username123
331 User username123i OK. Password required
PASS ***********
230 OK. Current restricted directory is /
SYST
215 UNIX Type: L8
FEAT
211-Extensions supported:
EPRT
IDLE
MDTM
SIZE
MFMT
REST STREAM
MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
MLSD
AUTH TLS
PBSZ
PROT
TVFS
ESTA
PASV
EPSV
SPSV
ESTP
211 End.
OPTS UTF8 ON
504 Unknown command
Connect ok!
PWD
257 "/" is your current location
Чтение каталога...
TYPE A
200 TYPE is now ASCII
PASV
227 Entering Passive Mode (77,222,57,218,231,215)
MLSD
150 Accepted data connection
Загрузка
Ожидание ответа сервера...
226-Options: -a -l
226 170 matches total

It's from TotalCommander FTP client, connected to this FTP-server - and RU names are well visible, so - support is available, but how to activate\use ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
It's logcat text from logcat, after listing:
Sub FTP1_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)


TempDownload.png

TempDownload.png
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
So you can see in the following post that it worked. Why do you write

"But this should be used before the connection, but it's impossible, we have only Init method.
So, no use."

???

You need to find out the encoding that your server uses and set the encoding accordingly. This encoding will be used to parse the list result.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Yes, Erel, you are right, if to set "CP1251" encoding - it's OK !
"Used before connection" - it is always mentioned in Stackoverflow about this subject, but i did not know whet moment the connection is done.

So, no universal way to detect what encoding is needed for each FTP server ? Say, if files named on various languages...
 
Upvote 0
Top