Home > database >  MyUtil statement program convert utf-8 to tomcat with iso - 8859-1 to read simple and easy to code
MyUtil statement program convert utf-8 to tomcat with iso - 8859-1 to read simple and easy to code

Time:11-16

Package utils;

Import the Java. IO. UnsupportedEncodingException;

Public class MyUtil {
Public static String toUnicode (String s)
{
If (s==null | | s.e quals (" ")) {
Return s="";
}
Try {
S=new String (s.g etBytes (" iso - 8859-1 "), "utf-8");
//convert utf-8 to tomcat
} the catch (UnsupportedEncodingException e)
{
S=""; e.printStackTrace();
}

Return s;
}

Public static int toInt (String s)//String overall
{
If (s==null | | s.e quals (" ")) {
S="0";
}
int i=0;
Try {
I=Integer. ParseInt (s);
} the catch (Exception e)
{
I=0;
e.printStackTrace();
  • Related