ilan Expert Licensed User Longtime User Apr 29, 2020 #1 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
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 Apr 29, 2020 #2 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
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.
ilan Expert Licensed User Longtime User Apr 29, 2020 #3 drgottjr said: 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. Click to expand... 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
drgottjr said: 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. Click to expand... 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?
Semen Matusovskiy Well-Known Member Licensed User Apr 30, 2020 #4 Execute ftp.list and take a look a list of files in Code: Copy 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
Execute ftp.list and take a look a list of files in Code: Copy 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 ?
drgottjr Expert Licensed User Longtime User Apr 30, 2020 #5 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
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.)
ilan Expert Licensed User Longtime User Apr 30, 2020 #6 Semen Matusovskiy said: Where do you see ????? ???? ????.mp4 ? In Windows FTP client ? Click to expand... 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
Semen Matusovskiy said: Where do you see ????? ???? ????.mp4 ? In Windows FTP client ? Click to expand... 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.
Erel B4X founder Staff member Licensed User Longtime User Apr 30, 2020 #7 Your FTP client probably uses an encoding other than UTF8. Dealing with non-ASCII file names in FTP can be challenging. As you are sending the files from the B4J app, you can base64-encode the files names before they are sent and decode them on the device. Last edited by a moderator: Jun 29, 2020 Upvote 0
Your FTP client probably uses an encoding other than UTF8. Dealing with non-ASCII file names in FTP can be challenging. As you are sending the files from the B4J app, you can base64-encode the files names before they are sent and decode them on the device.
ilan Expert Licensed User Longtime User Apr 30, 2020 #8 Erel said: Your FTP client probably uses an encoding other than UTF8. Click to expand... its the b4j.net library, can i set it to UTF8 when uploading files? Erel said: you can base64-encode the files names before they are sent and decode them on the device. Click to expand... i was searching for more info about that solution and what i found a solution with stringutils library. so i tried this code: B4X: Copy 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 Click to expand... but if i try this: B4X: Copy 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) Click to expand... Upvote 0
Erel said: Your FTP client probably uses an encoding other than UTF8. Click to expand... its the b4j.net library, can i set it to UTF8 when uploading files? Erel said: you can base64-encode the files names before they are sent and decode them on the device. Click to expand... i was searching for more info about that solution and what i found a solution with stringutils library. so i tried this code: B4X: Copy 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 Click to expand... but if i try this: B4X: Copy 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) Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Apr 30, 2020 #9 Ilan take 10 minutes and learn about base 64 encoding. This is essential for developers. Code: Copy Dim FileNameWithHebrewChars As String = "אילן" Dim SafeFileName As String = su.EncodeBase64(FileNameWithHebrewChars .GetBytes("utf8")) Changing the FTP client encoding: https://www.b4x.com/android/forum/t...y-android-ftp-smtp-and-pop3.10892/post-456928 Upvote 0
Ilan take 10 minutes and learn about base 64 encoding. This is essential for developers. Code: Copy Dim FileNameWithHebrewChars As String = "אילן" Dim SafeFileName As String = su.EncodeBase64(FileNameWithHebrewChars .GetBytes("utf8")) Changing the FTP client encoding: https://www.b4x.com/android/forum/t...y-android-ftp-smtp-and-pop3.10892/post-456928