With IdFTP
, the server i'm connecting to is not using UTF-8, but ANSI. There's nothing special about my code, i simply set Host
, Username
, Password
and Connect to server. Then i call List
method with no parameters. Iterating through DirectoryListing
gives me incorrect results for file names. My sample directory name encoded in local code page (CP-1250) is:
aąęsśćńółżźz
I thought i'll be able to "fix" file name field by converting it to AnsiString
and setting code page but it seems to be already broken - memory dump of DirectoryListing[I].FileName
:
a ? ? s ? ? ? ?? ?? z 6100 FDFF FDFF 7300 FDFF FDFF FDFF 8FDB DFDF 7A00
Manipulating with GIdDefaultAnsiEncoding
or IOHandler.DefStringEncoding
(after Connect, before List) makes no difference. I don't want to mess in IdFTP
or IdGlobal
code because i'm using it with other projects that involve Unicode and these works perfectly. Delphi XE2 or XE7.
As you can see FData
contains raw file name in a 2 bytes per char string:
Even if i set IOHandler.DefStringEncoding
to any TIdTextEncoding
that is FIsSingleByte = True
, FMaxCharSize = 1
. However it looks promising because #$009F is "ź" in CP-1250, but i'm not looking for a per server, temporary solution. I expected Indy to handle this correctly after setting IOHandler.DefStringEncoding
and GIdDefaultAnsiEncoding
based on server capabilities (UTF-8 or ANSI with specified encoding).
Total Commander connection log: