: This article describes how to solve the problem of garbled Chinese characters in the downloaded files of IE11. if you are interested in the PHP Tutorial, refer to it. IE 11 found garbled characters when downloading files.
After checking the information on the Internet, I learned that the user-agent has changed. it is no longer MSIE, and the plane is rv: 11.0. Therefore, as long as the server determines that it is IE 11, same as MSIE.
GO:
funcsetDownloadFileName(whttp.ResponseWriter,fileName,agentstring){
ifstrings.Contains(agent,"MSIE"){
fileName=url.QueryEscape(fileName)
fileName=strings.Replace(fileName,"+","%20",-1)
}
ifstrings.Contains(agent,"rv:")&&strings.Contains(agent,"Gecko"){
fileName=url.QueryEscape(fileName)
fileName=strings.Replace(fileName,"+","%20",-1)
}
w.Header().Set("Content-Disposition","attachment;filename=\""+fileName+"\"")
}
PHP:
$ua = isset ( $_SERVER ["HTTP_USER_AGENT"] ) ? $_SERVER ["HTTP_USER_AGENT"] : '';if (preg_match ( "/MSIE/", $ua )) {$file_name = rawurlencode ( $file_name );header ( 'Content-Disposition: attachment; filename="' . $file_name . '"' );} else if (preg_match ( "/Firefox/", $ua )) {header ( 'Content-Disposition: attachment; filename*="utf8\'\'' . $file_name . '"' );} elseif (stripos ( $ua, 'rv:' ) > 0 && stripos ( $ua, 'Gecko' ) > 0) {$file_name = rawurlencode ( $file_name );header ( 'Content-Disposition: attachment; filename="' . $file_name . '"' );} else {header ( 'Content-Disposition: attachment; filename="' . $file_name . '"' );}
The above describes how to solve the go/php problem by downloading files in IE 11 in Chinese, including some content. I hope my friends who are interested in the PHP Tutorial can help me.