protected static String convertToUTF8(String s) {
if (s == null || s.length() == 0)
return s;
byte[] b;
try {
b = s.getBytes("ISO8859_1");
for (int i = 0; i < b.length; i++)
if (b[i] + 0 < 0)
return new String(b, "UTF-8");
b = s.getBytes("UTF-8");
for (int i = 0; i < b.length; i++)
if (b[i] + 0 < 0)
return new String(b, "UTF-8");
} catch (Exception e) {
}
return s;
}
convertToUTF8
最新推荐文章于 2024-03-18 09:44:13 发布