Filename Encoding

Giganews Newsgroups
Subject: Filename Encoding
Posted by:  J. Eisenheim (j.eisenhe…@gmail.com)
Date: Sat, 11 Dec 2010

Hi,

With the latest Indy10 snapshot (4533) and pre-Delphi2009 I have
problems with unicode filenames and TidFTP.
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. 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. The result is that a directory is created with strange
characters and listing a unicode folder will return an ansistring like
?????????.

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.

Question: it is possible to get same result in a more elegant way (an
ifdef or property)?

Thank you.

Replies