public static void testCharset(String datastr){
try {
String temp = new String(datastr.getBytes(), "GBK");
Log.v("TestCharset","****** getBytes() -> GBK ******\n"+temp);
temp = new String(datastr.getBytes("GBK"), "UTF-8");
Log.v("TestCharset","****** GBK -> UTF-8 *******\n"+temp);
temp = new String(datastr.getBytes("GBK"), "ISO-8859-1");
Log.v("TestCharset","****** GBK -> ISO-8859-1 *******\n"+temp);
temp = new String(datastr.getBytes("ISO-8859-1"), "UTF-8");
Log.v("TestCharset","****** ISO-8859-1 -> UTF-8 *******\n"+temp);
temp = new String(datastr.getBytes("ISO-8859-1"), "GBK");
Log.v("TestCharset","****** ISO-8859-1 -> GBK *******\n"+temp);
temp = new String(datastr.getBytes("UTF-8"), "GBK");
Log.v("TestCharset","****** UTF-8 -> GBK *******\n"+temp);
temp = new String(datastr.getBytes("UTF-8"), "ISO-8859-1");
Log.v("TestCharset","****** UTF-8 -> ISO-8859-1 *******\n"+temp);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
try {
String temp = new String(datastr.getBytes(), "GBK");
Log.v("TestCharset","****** getBytes() -> GBK ******\n"+temp);
temp = new String(datastr.getBytes("GBK"), "UTF-8");
Log.v("TestCharset","****** GBK -> UTF-8 *******\n"+temp);
temp = new String(datastr.getBytes("GBK"), "ISO-8859-1");
Log.v("TestCharset","****** GBK -> ISO-8859-1 *******\n"+temp);
temp = new String(datastr.getBytes("ISO-8859-1"), "UTF-8");
Log.v("TestCharset","****** ISO-8859-1 -> UTF-8 *******\n"+temp);
temp = new String(datastr.getBytes("ISO-8859-1"), "GBK");
Log.v("TestCharset","****** ISO-8859-1 -> GBK *******\n"+temp);
temp = new String(datastr.getBytes("UTF-8"), "GBK");
Log.v("TestCharset","****** UTF-8 -> GBK *******\n"+temp);
temp = new String(datastr.getBytes("UTF-8"), "ISO-8859-1");
Log.v("TestCharset","****** UTF-8 -> ISO-8859-1 *******\n"+temp);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}