I'd need to convert a file name to be up/downloaded to/from a FTP server. So, special characters with accents, umlauts and other symbols should be replaced in a form to still keep a readable file name.
I could do search and replace for a list of chars and replace as seen in the following list
Ä>Ae|ä>ae|Ö>Oe|ö>oe|Ü>Ue|ü>ue|ß>ss|à>a|á>a|â>a|è>e|é>e|é>e||ê>e|Á>A|À>A|É>E|È>E|:>-|·>-|•>-|–>-|—>-|*>-|">'|\>-
But is there a more effective solution?
Convert file name for FTP server
- Michael Vogel
- Addict
- Posts: 2677
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Convert file name for FTP server
The FTP server should be able to handle umlauts.
Maybe it's a problem with the FTP client that can only handle ASCII.
Try converting the file name to UTF8. The FTP server should understand UTF8.
Maybe it's a problem with the FTP client that can only handle ASCII.
Try converting the file name to UTF8. The FTP server should understand UTF8.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
- Michael Vogel
- Addict
- Posts: 2677
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Convert file name for FTP server
In my case it has to do with a media server (NAS) and a music player (Bluesound) which does not show up music files containing umlauts for example.
Some FTP implementation seem to support 7 bit ASCII characters only, so converting the file names is to avoid problems.
As a workaround I am using the following code, which does not consider all international characters.
Some FTP implementation seem to support 7 bit ASCII characters only, so converting the file names is to avoid problems.
As a workaround I am using the following code, which does not consider all international characters.
Code: Select all
Procedure.s StrFtpFileName(s.s)
Protected.s c,ftp
Protected.i i,n
n=Len(s)
While i<n
i+1
c=Mid(s,i,1)
Select Asc(c)
Case '<','>','*','?'
ftp+"-"
Case '"'
ftp+"'"
Case ':','\'
ftp+"."
Case 32 To 126
ftp+c
Case 'ä'
ftp+"ae"
Case 'ö'
ftp+"Oe"
Case 'ü'
ftp+"Ue"
Case 'Ä'
ftp+"Ae"
Case 'Ö'
ftp+"Oe"
Case 'Ü'
ftp+"Ue"
Case 'ß'
ftp+"ss"
Case 'à','á','â','å'
ftp+"a"
Case 'è','é','ê','ë'
ftp+"e"
Case 'ì','í','î','ï'
ftp+"i"
Case 'ò','ó','ô','õ'
ftp+"o"
Case 'ù','ú','û'
ftp+"u"
Case 'À','Á','Â','Å','Ã'
ftp+"A"
Case 'È','É','Ê','Ë'
ftp+"E"
Case 'Ì','Í','Î','Ï'
ftp+"I"
Case 'Ò','Ó','Ô','Õ'
ftp+"O"
Case 'Ù','Ú','Û'
ftp+"U"
Case 'ç'
ftp+"c"
Case 'ñ'
ftp+"n"
Case 'Ç'
ftp+"C"
Case 'Ñ'
ftp+"N"
Case 'æ'
ftp+"ae"
Case 'Æ'
ftp+"Ae"
Case '·','•','–','—','','',''
ftp+"-"
Default
ftp+" "
EndSelect
Wend
ProcedureReturn ftp
EndProcedure
Debug StrFtpFileName("Hallo äöüß ?!.;: ñëìæç *ok")