就是使用新的编码,把源字符串重新编码输出

解决方案 »

  1.   

    public class test {
      public static void main(String[] args) {
        String strEn = "May be you're right.";
        String strZN = "也许你是对的。";
        
        System.out.println(ISO8859_1_Encoder(strEn));
        System.out.println(ISO8859_1_Encoder(strZN));
        System.out.println(ISO8859_1_Encoder(strEn+strZN));
      }  private static String ISO8859_1_Encoder(String src){
        String strEncoded = null;
        byte[] tmpbyte;
        try{
          tmpbyte=src.getBytes("ISO8859_1");
          strEncoded=new String(tmpbyte);
        }
        catch(Exception e){
        }
        return strEncoded;
      }
    }