Re: Differing behavior in IdFTP between .NET and Win32 with Indy10 - High Ascii

Giganews Newsgroups
Subject: Re: Differing behavior in IdFTP between .NET and Win32 with Indy10 - High Ascii
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Thu, 22 Sep 2005

"Carl Hungerford" <chungerfo…@intoknow.com> wrote in message
news:B2B34AA535DBE240chungerfo…@intoknow.com...

>  IdFTP1.Get('001±ASSY.mod','C:\data\testfile.tmp',true);
>
>  the .Net version will fail giving the error that the filename,
> directory name or volume label syntax is incorrect. In the
> error the '±' is replaced with a '?' and no file is transferred.

Strings in .NET are 16-bit Unicode.  They have to be converted to 7-bit or
8-bit Ascii when transmitted over a socket for an Ascii-based protocol, such
as FTP.  Indy uses System.Text.Encoding.ASCII.GetBytes() to perform the
conversion to 7-bit Ascii.  Most Internet protocols use 7-bit strings.
According to MSDN:

    "ASCII characters are limited to the lowest 128 Unicode characters, from
U+0000 to U+007F."

The character you are trying to use is Ascii 241 (U+00F1).  Since .NET
cannot handle high Ascii characters in 7-bit strings, you end up with the
'?' character instead.

The original FTP spec says that all command strings have to be 7-bit, where
the high-order bit is not used.  Since the high-order bit is needed to
represent a high Ascii character, the only reliable way to send strings
containing high Ascii characters in FTP (Indy or otherwise) is if the FTP
server supports 8-bit command strings.  This is only the case for servers
that implement the MLST and MLSD extended FTP commands.  The draft that
declares the behavior for those commands also updates the FTP spec to allow
8-bit strings, as well as UTF-8 encoded paths and filenames (UTF-8 requires
the use of the high-order bit).  Indy can encode .NET Unicode strings to
UTF-8, though TIdFTP does not support that at this time.  Such functionality
would require code changes throughout TIdFTP's source.

So, to adress the original question - avoid filenames with high Ascii
characters whenever possible.  Only some of the most modern FTP servers will
be able to handle the high Ascii characters properly anyway.

Gambit

Replies

In response to

Differing behavior in IdFTP between .NET and Win32 with Indy10 - High Ascii cha posted by Carl Hungerford on Thu, 22 Sep 2005