ASPProgramThe response. Redirect "URL of the file to be downloaded" method is used to download the file. However, when the file name contains Chinese characters and users click Download and save, the file name is garbled in the Save As dialog box.
Solution:
1, when the browser "always send URL via UTF-8" removed
In this way, the URL will be sent through the default encoding of the operating system. The URL is treated as the default encoding of the operating system. In our IIS Chinese version, the default string encoding is gb2312 (GBK ). The client and the server are both encoded using gb2312 (GBK), so there will be no garbled characters.
This method is not suitable. Because we need to coordinate the client and server
2. When we know that IE processes the file name, it is handled as UTF-8 encoding by default, and our URL is sent in gb2312 encoding, so garbled characters may occur. Therefore, we only need to convert gb2312 encoding to UTF-8 encoding on the server side.
As follows:CodeAs shown in:
Defaultcodepage = session. codePage
Session. codePage = 65001 'utf-8
Pfilename = server. urlencode (pfilename) 'encode file name by UTF-8
Session. codePage = defacodecodepage 'Restore
<Script language = "JavaScript">
Window. navigate ("<% = pfilename %> ")
</SCRIPT>
Note that the above Code does not use: Response. Redirect pfilename
This is because the Redirect method will encode the string, which will encode % in pfilename as % 2e.