Getting encoding from FTP response

  • Thread starter Thread starter K Viltersten
  • Start date Start date
K

K Viltersten

I'll be retrieving file lists from different
FTP's and i can't know for sure what encoding
a certain server will use.

How can i determine it so i can use it in my
StreamReader object?
 
K said:
I'll be retrieving file lists from different
FTP's and i can't know for sure what encoding
a certain server will use.

How can i determine it so i can use it in my
StreamReader object?

See: Internationalization of the File Transfer Protocol
http://www.ietf.org/rfc/rfc2640.txt

If you can access the server features with the .Net Ftp client library,
you can check if the server uses Unicode (UTF8). The server indicates
the UTF8 encoding in its reply of a 'feat' command (for details, see
section 3.2, Servers compliance).

For non-Unicode enabled servers, things are not easy:

(from Section 3.3:) "How a client implementation handles non
UTF-8 is a quality of implementation issue. It MAY try to assume
some other encoding, give the user a chance to try to assume
something, or save encoding assumptions for a server from one FTP
session to another."


Best Regards
 
I'll be retrieving file lists from different
See: Internationalization of the File Transfer Protocol
http://www.ietf.org/rfc/rfc2640.txt

If you can access the server features with the .Net Ftp client library,
you can check if the server uses Unicode (UTF8). The server indicates the
UTF8 encoding in its reply of a 'feat' command (for details, see section
3.2, Servers compliance).

For non-Unicode enabled servers, things are not easy:

(from Section 3.3:) "How a client implementation handles non
UTF-8 is a quality of implementation issue. It MAY try to assume
some other encoding, give the user a chance to try to assume
something, or save encoding assumptions for a server from one FTP
session to another."

Bad news. Thanks, anyway.
 
K said:
Bad news. Thanks, anyway.

I would not expect FEAT to be implemented and to be implemented
correctly.

You will very likely need to guess encoding yourself.

If you get a Stream, then you can specify Encoding for
StreamReader/StreamWriter.

Arne
 
Back
Top