Re: Filename Encoding

Giganews Newsgroups
Subject: Re: Filename Encoding
Posted by:  Remy Lebeau \(Indy Team\) (re…
Date: Mon, 13 Dec 2010

"J. Eisenheim" <j.eisenhe…> wrote in message

> With the latest Indy10 snapshot (4533) and pre-Delphi2009
> I have problems with unicode filenames and TidFTP.

Supporting Ansi for FTP is very problematic with all the Unicode changes in
place now.  I have an Ansi-enabled version of TIdFTP in my local copy of
Indy, and it is quite ugly with IFDEFs all over the place.  Things wil be
cleaner in Indy 11, as we are considering going to an all-Unicode interface
so Ansi will not be an issue anymore.

> I want to create a directory with unicode characters, so I
> encode the WideString to UTF and then I pass it to MakeDir
> as ansistring.

That will not work.  Encode the directory name using the OS's default Ansi
encoding instead, and then Indy can convert that to UTF-8 internally for you
if the server supports UTF-8.

> In the similar way I decode the UTF string to unicode when using List.
> This is worked before but it seems that now Indy tries to encode/decode
> the filenames itself.

Yes, because it is supposed to.

> The solution is to uncomment the lines
>    if ASrcEncoding <> ADestEncoding then begin
>      LBytes := TIdTextEncoding.Convert(ASrcEncoding, ADestEncoding,
> LBytes);
>    end;
> in IdGlobal ToBytes and BytesToString functions.

That is not going to happen.  That check needs to be there.

Remy Lebeau (TeamB)


In response to

Filename Encoding posted by J. Eisenheim on Sat, 11 Dec 2010