char a = 'a';
    int b = (int)a;
    System.err.println(" a ascii is " + b);    运行结果:
    a ascii is 97。

解决方案 »

  1.   

    兄弟,我要的不是这样。
      比如:
    String str="人生";
      然后我想将它转成--》 人生不知该怎么转哪?
      

  2.   

    please try this one.    /**
         * Convert native string to ISO-8859-1 encoding string
         * @param token Token
         * @param value String
         * @return String
         */
         
        public static String toIso88591String(String nativeEncoding, String value) {
            String newValue = value;
            String defaultEncoding = "iso-8859-1";
            if (!defaultEncoding.equals(nativeEncoding)) {
                try {
                    newValue = new String(newValue.getBytes(nativeEncoding),
                        defaultEncoding);
                } catch (UnsupportedEncodingException ex) {
                    ex.printStackTrace();
                }
            }
            return newValue;
        }
        
    String valueAfter = toIso88591String("gb2312", "中国");
      

  3.   

    public static String ConvertString(String s)
       {
        String s1 = "";
        if(s != null && !s.equals(""))
        {
            int i = s.length();
            for(int j = 0; j < i; j++)
            {
                char c = s.charAt(j);
                s1 = s1 + "&#x" + Integer.toHexString(c) + ";";
            }    }
        return s1;
       }