看看这个
http://expert.csdn.net/Expert/topic/989/989888.xml?temp=8.301944E-02

解决方案 »

  1.   

    import java.io.*;
    public class test 
    {
    public static void main(String[] args) 
    {
      try{
    String str = "中文";
    String tmp = ChineseToUnicode(str);
    String iso = new String(tmp.getBytes("ISO8859_1"),"GBK");
    System.out.println("-----"+iso+"---");
    String gbk = new String(tmp.getBytes("GBK"),"ISO8859_1");
    System.out.println("-----"+gbk+"---");
    System.out.println("-----"+tmp+"---");
    System.out.println("begin");
    if (tmp.equals(gbk))
    System.out.println("this is ISO8859_1");
    if (tmp.equals(iso))
    System.out.println("this is GBK");
      }catch(Exception e)
    {
      System.out.println(e);
    }
    }
    public static String UnicodeToChinese(String s){ 
      try{ 
         if(s==null||s.equals("")) return ""; 
         String newstring=null; 
         newstring=new String(s.getBytes("ISO8859_1"),"GBK"); 
         return newstring; 
        } 
      catch(UnsupportedEncodingException e) 
      { 
      return s; 
      } 
      } public static String ChineseToUnicode(String s){ 
      try{ 
      if(s==null||s.equals("")) return ""; 
      String newstring=null; 
      newstring=new String(s.getBytes("GBK"),"ISO8859_1"); 
       return newstring; 
      } 
      catch(UnsupportedEncodingException e) 
      { 
      return s; 
     } 
      }
    }
      

  2.   

    如果你判断一串char是那种编码的数据,只能依赖对编码特性的了解,而且,比如abc的内码,采用各种编码都一样,所以,你不一定总是能够正确判断。
    如果,你是想得到本地系统的却省编码形式,直接到jvm的系统变量中取好了,dojsp(月下秋风)提供的那段程序真是在胡扯,而
    http://expert.csdn.net/Expert/topic/989/989888.xml?temp=8.301944E-02
    这段程序就更离谱了~
      

  3.   

    jvm的系统变量的说法不准确,就是缺省的Local中取
      

  4.   

    谢谢yannqi和dojsp给了我思路,问题解决了。