FTP and accented characters in filenames [solved]

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: FTP and accented characters in filenames

Post by MaxV » Tue Oct 03, 2017 1:31 pm

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
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: FTP and accented characters in filenames

Post by ittarter » Tue Oct 03, 2017 5:56 pm

MaxV wrote:
Tue Oct 03, 2017 1:31 pm
Where?
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.

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: FTP and accented characters in filenames

Post by shaosean » Tue Oct 03, 2017 5:59 pm

You might want to look at writing your own FTP socket so you can use the UTF8 FEAT, if your server supports it..

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: FTP and accented characters in filenames

Post by jacque » 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: FTP and accented characters in filenames

Post by shaosean » Wed Oct 04, 2017 6:57 am

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..

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: FTP and accented characters in filenames

Post by ittarter » Fri Oct 06, 2017 8:49 am

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.

Post Reply