我想将字符串转换为 EUC-JP 编码方式,但不知道以前的编码方式,是否可以转换?

解决方案 »

  1.   

    在java中,任何字符了类型的数据在java中均以Unicode字符表示,如char , string 等类型
    String str = "  abc "  //abc是你指定的字符串
    byte[] bytes = str.getBytes();
    bytes = str.getBytes("EUC-JP");
      

  2.   

    像 这种方式对吗?在java中,任何字符了类型的数据在java中均以Unicode字符表示,如char   ,   string   等类型 
    String   str   =   "     abc   "     //abc是你指定的字符串 
    byte[]   bytes   =   str.getBytes(); 
    bytes   =   str.getBytes("EUC-JP");
      

  3.   

    前几天做过一个关于JAVAMAIL的程序,也涉及到了许多关于字符编码的问题,但是好像不可以获得字符串的编码方式~
    LZ 好运 ^_^
      

  4.   

    String str="要进行字符转换的字符转";
    String s = new String(str.getBytes("原来字符串的编码方式"),"EUC-JP");