FTP charset - Optional parameter or auto detection

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

FTP charset - Optional parameter or auto detection

Post by RSBasic »

Good Morning :)

I have a problem. I download any files with ReceiveFTPFile().
Some file names contain german umlauts (ä, ö, ü) or other special characters (ß) but FTPDirectoryEntryName() shows wrong file names.
My server uses the charset UTF-8 but PureBasic receives ASCII.

My example code:

Code: Select all

EnableExplicit

InitNetwork()

If OpenFTP(1, "rsbasic.de", "webika3rg_qch3ai", "PureBasic!2016")
  If ExamineFTPDirectory(1)
    While NextFTPDirectoryEntry(1)
      Debug FTPDirectoryEntryName(1)
    Wend
  EndIf
 
  CloseFTP(1)
EndIf
I can't find the parameter to change of charset. The FTP client "FileZilla" has a charset function but PureBasic hasn't this.

I can convert the string to UTF-8 with UTF8() or with:

Code: Select all

Procedure.s AsciiToUTF8(String$)
  Protected Buffer$
 
  Buffer$ = Space(Len(String$))
  PokeS(@Buffer$, String$, -1, #PB_Ascii)
  String$ = PeekS(@Buffer$, -1, #PB_UTF8)
 
  ProcedureReturn String$
EndProcedure
But this is a workaround. :(

Can you add the charset parameter for OpenFTP() or a auto detection function?

Thank you :)
Image
Image
User avatar
mhs
Enthusiast
Enthusiast
Posts: 101
Joined: Thu Jul 02, 2015 4:53 pm
Location: Germany
Contact:

Re: FTP charset - Optional parameter or auto detection

Post by mhs »

+1
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: FTP charset - Optional parameter or auto detection

Post by IdeasVacuum »

+1
Same issue: CreateFTPDirectory(0, "报 报 报")
Unicode characters not supported (result is ???)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: FTP charset - Optional parameter or auto detection

Post by IdeasVacuum »

Given that PB is Unicode now, shouldn't this issue be classed as a bug?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: FTP charset - Optional parameter or auto detection

Post by Bisonte »

No it's not a bug, because FTP is always ASCII : so the specification RFC959.

Other charsets are additional features of the RF959, this is RFC2640.

But on some servers the authentification with OpenFTP() failed, so I think, at the change to unicode, Fred forget the FTP lib to
make it compatible (I mean that the ftp lib send and receive ASCII).

But I support the request to add the charset option or autodetection so : +1
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: FTP charset - Optional parameter or auto detection

Post by IdeasVacuum »

You are right Bisonte.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: FTP charset - Optional parameter or auto detection

Post by RSBasic »

As long as this charset parameter does not exist, I can use my PB.Ex FTP.
Works very well with UTF-8 and has no umlaut problems.
Image
Image
Post Reply