Analysis on the problem that Chinese attachments cannot be downloaded

Source: Internet
Author: User

Details: After clicking the attachment, the correct path (*/test .doc, which can be downloaded after the test) appears in the browser's address bar, but the expected dialog box for opening/downloading is not displayed, however, "webpage cannot be displayed" is displayed ". But there is a DOC file. After comparison, the only difference is that the file name can contain 11 Chinese characters, while the other two are 8 or 10 Chinese characters, that is, an even number will cause an error, it's really amazing.
Baidu searched for the following information: Article .
On the Internet, I often see someone asking this question: "My file name is in Chinese. I put it on the Web server for someone to download, but I always prompt that the file cannot be found, but is the file clearly there? ". In the end, this problem is the encoding problem. utf8, GBK, and big5 have a headache at a glance.
For this problem, there are also a number of solutions on the Internet, such as encoding the file name of the request, or, you can remove the check box that is always sent in UTF-8 encoding at the bottom of the IE-> tool --> Option --> advanced, that is, you do not need to use UTF-8 encoding to send URLs, however, because IE is sent in UTF Encoding by default, everyone needs to change the IE settings.
The general cause of this problem is that IE uses utf8 encoding for the Chinese characters in the URL ---> after the Web server receives the URL, it needs to be decoded. Different web server decoding rules are also different, however, the decoding is generally based on the default character set. For example, the Chinese system is generally GBK, and the resulting encoding is naturally wrong.
My machine environment is: Win2000 Chinese + iis5. Let's create an experiment.
1. Create a new file under the web root directory named "ciqinqiang .txt" and the content is ciqinqiang. When we access http: // 127.0.0.1/ciqinqiang .txt through the webpage, we find that this problem is correct and the file content can be displayed normally.
2. Create another file "qinqiang .txt" with the content of qinqiang. We accessed http: // 127.0.0.1/qinqiang .txt through the webpage and found that the webpage could not be found.
3. Create another file "zookeeper .txt" with the content garbled ". We accessed http: // 127.0.0.1/ .txt through the webpage and found that there is no problem and it can be displayed normally.
4. In this case, we can access http: // 127.0.0.1/qinqiang .txt again. We found that the access was available again, but unfortunately, the content we wanted was not "qinqiang ", it is the content of the "Garbled text", that is, the "ゅ.txt .txt" file.
At this point, we should be able to understand that "qinqiang" is decoded by using GBK after UTF-8 encoding, and is decoded as "qinqiang ". Encoding is a tedious task. We will not analyze it in depth here. As long as you know utf8 encoding, Chinese will be encoded into three bytes, unicode and GBK are both two bytes. for example, after being UTF-8 encoded, qinqiang becomes % E5 % 8B % A4 % E5 % BC % Ba, with 6 bytes in total, % E5 % 8B % A4 is diligence % E5 % BC % Ba is strong.
IIS decoding is based on two bytes and one Chinese character, that is, % E5 % 8B is decoded into one word according to GBK, % A4 % E5 one % BC % Ba represents one word. We can check the GBK encoding table and find that e58b is Taobao, a4e5 is Taobao, and bcba is your own.
Therefore, for IIS, if you have to use a Chinese file name, the number of Chinese words should be odd, so there should be no problem (my conclusion from this machine, it may not be suitable for other words). For example, if the word ". txt" is displayed normally, even numbers may cause problems. For example, "We are all children. txt ". This may not be the case for other Web servers, such as Apache.

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.