//Chinese code into UTF-8
//fileName = new String(fileName.getBytes("GBK"), "ISO-8859-1");
String agent = ServletActionContext.getRequest().getHeader("USER-AGENT");
if (null != agent){
if (-1 != agent.indexOf("Firefox")) {//Firefox
fileName = "=?UTF-8?B?" + (new String(org.apache.commons.codec.binary.Base64.encodeBase64(fileName.getBytes("UTF-8"))))+ "?=";
}else if (-1 != agent.indexOf("Chrome")) {//Chrome
fileName = new String(fileName.getBytes(), "ISO8859-1");
} else {//IE7+
fileName = java.net.URLEncoder.encode(fileName, "UTF-8");
fileName = fileName.replaceAll("\\+", "%20");
}
}
开始是用fileName = new String(fileName.getBytes("GBK"), "ISO-8859-1");这种方式转码,但是在繁体系统里会有乱码问题。
针对然后改为针对浏览器的分类转码。达到了预期的效果。
3万+

被折叠的 条评论
为什么被折叠?



