native2ascii.exe

native2ascii.exe
配置文件里的中文,用JDK的native2ascii.exe可以编码,特别好用,自己写了段代码实现如下: 
public   class  ToUnicode { 
    
public   static  String convert(String s) { 
       
// 判断传入字符串是否为中文:取第一个字符判断其字节数 
         if (s.substring( 0 , 1 ).getBytes().length == 2 ){ 
            String unicode 
=   ""
            char [] charAry  =   new   char [s.length()]; 
            
for ( int  i = 0 ; i < charAry.length; i ++ ) { 
                charAry 
=  ( char )s.charAt(i); 
                unicode
+= " \\u "   +  Integer.toString(charAry,  16 ); 
            } 
return  unicode; 
        }
else
            
return  s; 
        } 
    } 
}

你可能感兴趣的:(native2ascii.exe)