FTP get Chinese file name garbled problem

Source: Internet
Author: User
Tags character set file upload ftp filezilla

Problem Description:

An FTP server was built on the server with FileZilla server, and the FTP in the Apache.commons.net package was used in the native program. FtpClient class upload download file, file upload download the filename after the display of the wood is a problem, that is, in the program using ListNames (), or listfiles () to get the file name, the Chinese filename will be garbled, like "???. PNG "like this.

Workaround:

Search on the Internet, said the code does not match, to get the file name, with Name=new String (name.getbytes ("UTF-8"), "GBK"); Such a way, of course, is not necessarily the two encodings, the order is not always. But after trying it, it's useless.

Then finally found a clear explanation: http://lioncn.blog.51cto.com/1557898/432835; Because the server-side character set and the client character set do not match, FileZilla Server uses Utf-8 by default. And our operating system is generally Chinese, the default character set is GBK, so it is not. It is recommended to use a special version of FileZilla server or patching, the easiest way is to send a command to the FTP server "opts UTF8 off", everything OK.

Testing on the client is feasible, but what to do in the program, call FtpClient's DoCommand ("opts", "UTF8 off");


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.