UTF-8编码转换为ISO-9959-1
public static String utf8ToIso88591(String str) {
if (str == null) {
return str;
}
try {
return new String(str.getBytes("UTF-8"), "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
ISO-9959-1编码转换为UTF-8
public static String iso88591ToUtf8(String str) {
if (str == null) {
return str;
}
try {
return new String(str.getBytes("ISO-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e.getMessage(), e);
}
}