package com.yangjia.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
public class StrToPrint {
//将GB2312编码方式转换为ISO8859_1编码方式
public static String GBToUnicode(String strIn) {
String strOut = null;
if (strIn == null || strIn.trim().equals(""))
return strIn;
try {
byte b[] = strIn.getBytes("GB2312");
strOut = new String(b, "ISO8859_1");
} catch (Exception e) {
}
return strOut;
}
//将ISO8859_1编码方式转换为utf-8编码方式
public static String UnicodeToUTF8(String strIn) {
String strOut = null;
if (strIn == null || strIn.trim().equals(""))
return strIn;
try {
byte b[] = strIn.getBytes("ISO8859_1");
strOut = new String(b, "utf-8");
} catch (Exception e) {
}
return strOut;
}
}
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
public class StrToPrint {
//将GB2312编码方式转换为ISO8859_1编码方式
public static String GBToUnicode(String strIn) {
String strOut = null;
if (strIn == null || strIn.trim().equals(""))
return strIn;
try {
byte b[] = strIn.getBytes("GB2312");
strOut = new String(b, "ISO8859_1");
} catch (Exception e) {
}
return strOut;
}
//将ISO8859_1编码方式转换为utf-8编码方式
public static String UnicodeToUTF8(String strIn) {
String strOut = null;
if (strIn == null || strIn.trim().equals(""))
return strIn;
try {
byte b[] = strIn.getBytes("ISO8859_1");
strOut = new String(b, "utf-8");
} catch (Exception e) {
}
return strOut;
}
}