package com.core;
import java.io.UnsupportedEncodingException;
public class StringUtils {
public static String toChinese(String strvalue){
try {
if(strvalue==null){
strvalue="";
}else{
strvalue=new String(strvalue.getBytes("ISO-8859-1"),"gbk");
strvalue=strvalue.trim();
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return strvalue;
}
public static final String filterStr(String str){
str=str.replaceAll(";", "");
str=str.replaceAll("&", "&");
str=str.replaceAll("<", "<");
str=str.replaceAll(">", ">");
str=str.replaceAll("'", "");
str=str.replaceAll("--"," ");
str=str.replaceAll("/", "");
str=str.replaceAll("%", "");
return str;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(toChinese("你好"));
}
}
import java.io.UnsupportedEncodingException;
public class StringUtils {
public static String toChinese(String strvalue){
try {
if(strvalue==null){
strvalue="";
}else{
strvalue=new String(strvalue.getBytes("ISO-8859-1"),"gbk");
strvalue=strvalue.trim();
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return strvalue;
}
public static final String filterStr(String str){
str=str.replaceAll(";", "");
str=str.replaceAll("&", "&");
str=str.replaceAll("<", "<");
str=str.replaceAll(">", ">");
str=str.replaceAll("'", "");
str=str.replaceAll("--"," ");
str=str.replaceAll("/", "");
str=str.replaceAll("%", "");
return str;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(toChinese("你好"));
}
}