网上看到一篇写Properties的代码,但是不明白的是,无论是读还是写,它都将字符从先通过ISO-8859-1解码然后再转成GB2312这是什么呢?private static String ISO2GB(String source) {
if (source == null || source.length() == 0) {
return "";
} String target = source;
try {
target = new String(source.getBytes("8859_1"), "GB2312");
} catch (Exception e) {
e.printStackTrace();
System.out.println("由ISO-8859-1到GB2312转码失败!");
}
return target;
}
if (source == null || source.length() == 0) {
return "";
} String target = source;
try {
target = new String(source.getBytes("8859_1"), "GB2312");
} catch (Exception e) {
e.printStackTrace();
System.out.println("由ISO-8859-1到GB2312转码失败!");
}
return target;
}
其它字符编码不用,无乱码现象