url 传中文

时间:2014-11-21 18:16:37   收藏:0   阅读:408

if (null == keyword || keyword.equals("关键字")) keyword = "";
if(keyword.length()> 0 ){
boolean isEnChar = true;
for(int i = 0 ; i < keyword.length() ; i++){
int charIndex = keyword.charAt(i);
if(charIndex >= 19968){
isEnChar = false;
break;
}
}
if(isEnChar){
try {
keyword = new String(keyword.getBytes("iso-8859-1"),"utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
this.keyword = keyword;

在keyword的set方法中这么一搞,一了百了.

 

原文:http://www.cnblogs.com/yanjunwu/p/4113442.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!