CSDN博客

img ladofwind

GB编码转UTF

发表于2004/12/29 15:15:00  1027人阅读

    public static String GBtoUTF(String gb2312String) {
        if (gb2312String == null) {
            return null;
        }
        System.out.println(gb2312String.length());
        StringBuffer sb = new StringBuffer(gb2312String.length() * 8);

        int j = 0;
        for (int i = 0; i < gb2312String.length(); i++) {
            j = gb2312String.charAt(i);
            sb.append("&#x");
            sb.append(Integer.toHexString(j).toUpperCase());
            sb.append(";");
        }
        return sb.toString();
    }

0 0

相关博文

我的热门文章

img
取 消
img即使是一小步
也想与你分享
打开
img