且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在java中将UTF-16 unicode字符转换为UTF-8

更新时间:2023-09-11 22:01:46

try {
    // Convert from Unicode to UTF-8
    String string = "\u003c";
    byte[] utf8 = string.getBytes("UTF-8");

    // Convert from UTF-8 to Unicode
    string = new String(utf8, "UTF-8");
} catch (UnsupportedEncodingException e) {
}

引用 http://www.exampledepot.com/egs/java.lang/unicodetoutf8.html