iOS Question File Name issue when loading to ftp

ilan

Expert
Licensed User
Longtime User
hi

i am using b4x ftp server implementation and when i upload a file with hebrew characters it arrives like this on my ftp server:

????? ???? ????.mp4

is there a way that it will arrive correctly?

thanx, ilan
 

drgottjr

Expert
Licensed User
Longtime User
do you know that the file arrived incorrectly or that the name was simply displayed incorrectly? hebrew characters would be unicode. whoever is showing the question marks is utf-8 (or similarly) based. the hebrew characters can't be displayed correctly.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
do you know that the file arrived incorrectly or that the name was simply displayed incorrectly? hebrew characters would be unicode. whoever is showing the question marks is utf-8 (or similarly) based. the hebrew characters can't be displayed correctly.

i believe that when it is arrived and saved it saved with ??? and not with hebrew characters. is there a possibility to set utf-8 to strings when i upload a file to ftp server?
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Execute ftp.list and take a look a list of files in
B4X:
Sub ftp_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
    For Each x As FTPEntry In Files
        Log (x.Name)
    Next       
End Sub
Guess, you will see expected names.

Where do you see ????? ???? ????.mp4 ? In Windows FTP client ?
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
you're better off using http(s) instead of ftp. almost everything you upload and download nowadays is via http(s). or scp (secure copy).

if you have to use ftp, you need to google "ftp unicode" and study a little. it's not totally clear. if the client is, in fact, sending a file name in unicode, then the server has to be able to accept it in unicode. your client may be sending the ?????'s. the actual contents of the file have to go a certain way (7-bit), but there is an extension for ftp to deal with file names in unicode. (these transport protocols were written years ago when the world spoke ascii.)
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Where do you see ????? ???? ????.mp4 ? In Windows FTP client ?

the ftp server is on my iPhone. i use this example: https://www.b4x.com/android/forum/t...plemented-with-socket-and-asyncstreams.74320/

so basically i have a ftp server running on my iphone (b4i app) and from my desktop i connect to it using a b4j app. when i upload a file it arrives on my b4i app with those characters ?????.mp4. but only if the name is in hebrew. if it is in english everything works fine.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Your FTP client probably uses an encoding other than UTF8.

its the b4j.net library, can i set it to UTF8 when uploading files?

you can base64-encode the files names before they are sent and decode them on the device.

i was searching for more info about that solution and what i found a solution with stringutils library.

so i tried this code:

B4X:
    Dim su As StringUtils
    Dim b() As Byte
    b = su.DecodeBase64("ilan")

    For i = 0 To b.Length - 1
        Log(b(i))
    Next

and thats the logs:

Waiting for debugger to connect...
Program started.
-118
86
-89

but if i try this:

B4X:
    Dim su As StringUtils
    Dim b() As Byte
    b = su.DecodeBase64("אילן")

    For i = 0 To b.Length - 1
        Log(b(i))
    Next

i get this:

Waiting for debugger to connect...
Program started.
Error occurred on line: 18 (Main)
java.io.IOException: Bad Base64 input character decimal 63 in array position 0
at anywheresoftware.b4a.objects.Base64.decode(Base64.java:1204)
at anywheresoftware.b4a.objects.Base64.decode(Base64.java:1259)
at anywheresoftware.b4a.objects.Base64.decode(Base64.java:1227)
at anywheresoftware.b4a.objects.StringUtils.DecodeBase64(StringUtils.java:36)
at b4j.example.main._appstart(main.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.start(main.java:38)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
at java.lang.Thread.run(Thread.java:748)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top