The Encoding property returns one of the following integer
values:
Value |
Description |
ftpEncodingANSI |
File names are sent as 8-bit characters using the default
character encoding for the current codepage. If the Unicode
version of the functions are used, file names are converted
from Unicode to ANSI using the current codepage before being
sent to the server. This is the default encoding type. |
ftpEncodingUTF8 |
File names that contain non-ASCII characters are sent using
UTF-8 encoding. This encoding type is only available on servers
that advertise support for UTF-8 encoding and permit that
encoding type to be enabled by the client. |
The Encoding property can be used to enable UTF-8 encoding
of file names, which provides improved support for the use of
international character sets. However, the server must provide
support for UTF-8 encoding by advertising it in response to the FEAT
command and it must support the OPTS command which is used to enable
UTF-8 encoding. If the server does not advertise support for UTF-8,
or the OPTS command fails with an error, then an exception will be
thrown and the encoding type will not change.
Although it is possible to use the Features property to
explicitly enable the ftpFeatureUTF8 feature, this is not
recommended. If the server has not advertised support for UTF-8
encoding in response to the FEAT command, that typically indicates
that UTF-8 encoding is not supported. Attempting to force UTF-8
encoding can result in unpredictable behavior when file names contain
non-ASCII characters.
It is important to note that not all FTP servers support UTF-8
encoding, and in some cases servers which advertise support for UTF-8
encoding do not implement the feature correctly. For example, a
server may allow a client to enable UTF-8 encoding, but once enabled
will not permit the client to disable it. Some servers may advertise
support for UTF-8 encoding, however if the underlying file system
does not support UTF-8 encoded file names, any attempt to upload or
download a file may fail with an error indicating that the file
cannot be found or created.