Chinese file names cannot be downloaded

Source: Internet
Author: User

Author: ciqinqiang
Http: // blog.csdn.net/cqq
*/


On the Internet, I often see someone asking this question: "My file name is in Chinese and I put it on the Web server for someone to download it,

But the system always prompts that the file cannot be found, but the file is clearly there ?". In the end, this problem is the encoding problem,

GBK and BIG5 are headaches at first glance.

For this problem, there are also a number of solutions on the Internet, such as encoding the request file name, or using the IE-> Tool

--> Option --> at the bottom of the advanced level, the check box is always removed by UTF8 encoding, that is, the URL is not sent by UTF8 encoding,

Because IE is sent in UTF Encoding by default, everyone needs to change iesettings.


The general cause of this problem is: IE uses UTF8 encoding for the Chinese characters in the URL ---> after the Web server receives the URL

Different WEB server decoding rules are different, but they are generally decoded using default character sets, such as Chinese systems.

Generally, it is GBK, so the code 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" with the content of ciqinqiang

We accessed http: // 127.0.0.1/ciqinqi.txt through the webpage and found 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 of "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,

However, unfortunately, the content is not what we hope to be "Diligent", but "garbled", that is, the content of 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"

 

Coding is a very tedious task, so we will not analyze it in depth here. As long as you know UTF8 encoding, Chinese will be encoded

Three bytes, while UnicodeGBK is two bytes. For example:


After being UTF-8 encoded, the word "Qin Qiang" becomes "% E5 % 8B % A4 % E5 % BC % BA". It has 6 bytes in total, and "% E5 % 8B % A4" is Qin Qiang.

% E5 % BC % BA is strong


IIS decoding is based on two bytes and one Chinese character, that is, % E5 % 8B is decoded into a word according to gbk, and % A4 % E5 is one

% BC % BA represents a 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 need to use a Chinese file name, the number of Chinese words should be odd, so there should be no problem.

(I come to the conclusion that this machine may not be suitable for anything else ),

For example, the word ". txt" can be displayed normally, and 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.