Page 2 of 2

Re: FTP and accented characters in filenames

Posted: Tue Oct 03, 2017 1:31 pm
by MaxV
ittarter wrote: Tue Oct 03, 2017 8:03 am And anyway, in the notes for urlencode, it says it's for HTTP servers only.
Where? However I'd read this: http://livecode.wikia.com/wiki/URLEncode

However first case, try this code:
########CODE to copy and paste#######
set the itemdel to "/"
put "ftp://" & item 1 of FtpFileName & "/" & urlencode(item 2 to -1 of FtpFileName) into FtpFileName2
set the itemdel to comma
put URL FtpFileName2 into url ("binfile:" & LocalFileName)
#####END OF CODE generated by http://tinyurl.com/j8xf3xq with livecode 9.0.0-dp-9#####

The second option is to know what is the server LOCALE, because it could be that server doesn't use UTF-8, or your lace, but it converts to a different locale so probably change one line to:

Code: Select all

put "ftp://" & item 1 of FtpFileName & "/" & urlencode(textencode(item 2 to -1 of FtpFileName , "CP1252") ) into FtpFileName2
or

Code: Select all

put "ftp://" & item 1 of FtpFileName & "/" & urlencode(textencode(item 2 to -1 of FtpFileName , "MacRoman") ) into FtpFileName2
or

Code: Select all

put "ftp://" & item 1 of FtpFileName & "/" & urlencode(textencode(item 2 to -1 of FtpFileName , "ISO-8859-1") ) into FtpFileName2

Re: FTP and accented characters in filenames

Posted: Tue Oct 03, 2017 5:56 pm
by ittarter
MaxV wrote: Tue Oct 03, 2017 1:31 pmWhere?
Well, more accurately, it says it's for HTTP, and there's no mention of FTP. e.g. line 1, "Returns a string that has been transformed so that it can be posted to an HTTP server as a URL."
However first case, try this code...(truncated)
This code yields zero usable files.


The second option is to know what is the server LOCALE, because it could be that server doesn't use UTF-8,
I'm not lacing my queries so it's not that. CP1252 works for cases without special characters, but unfortunately that leaves me where I started. I tried all the other ones in the list on this page http://livecode.wikia.com/wiki/TextEncode , using the script you provided, and most don't work for any files, and a couple (like "native") work just for filenames without special characters.

Thanks for all your help, no answers yet. I can rig something up to use filenames with only alphanumeric characters but it can't be my long-term solution.

Re: FTP and accented characters in filenames

Posted: Tue Oct 03, 2017 5:59 pm
by shaosean
You might want to look at writing your own FTP socket so you can use the UTF8 FEAT, if your server supports it..

Re: FTP and accented characters in filenames

Posted: Tue Oct 03, 2017 6:23 pm
by jacque
Try url encoding only the last item, the actual short file name, and leave the rest of the path as a quoted literal. The short name is the only thing that needs encoding.

Re: FTP and accented characters in filenames

Posted: Wed Oct 04, 2017 6:57 am
by shaosean
The only thing is the URLEncoded file name is not the same as the file name on the server.. I believe there is a specific way to encode the unicode file name for servers that do not support the UTF8 FEAT, which is noted in that RFC..

The files would need to be uploaded using the URLEncode function, on the file name, and when downloading, you would URLDecode them to get the unicode file names.. If your server supports the UTF8 FEAT you'd be better off using that..

Re: FTP and accented characters in filenames

Posted: Fri Oct 06, 2017 8:49 am
by ittarter
Hi Shaosean,

Thanks for the ideas, although I have no idea how to code anything outside of LC and a little html, much less an FTP socket. Somebody else set up the server -- I've contacted him and he may be able to help me with this next week.

I thought that maybe I could see what was going on server-end by calling the files from the folder in question, since there aren't any special characters outside of the filename itself:

Code: Select all

put files("ftp://name:password@IP/Conversations/Spanish 0101/Vocab/") into x
Unfortunately x is empty. Maybe that function doesn't work for files outside of my computer?

Alternately,

Code: Select all

put the files
doesn't work either, after setting defaultfolder to the above.
jacque wrote: Tue Oct 03, 2017 6:23 pm Try url encoding only the last item, the actual short file name, and leave the rest of the path as a quoted literal. The short name is the only thing that needs encoding.
I've definitely tried that multiple times. No dice.