?? encodingconvert.java
字號:
package jaoso.framework.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.UnsupportedEncodingException;
/**
* @author 邊緣孤客 edgeloner@yahoo.com.cn
* @since 2004-11-30
*/
public class EncodingConvert {
private static Log log = LogFactory.getLog(EncodingConvert.class);
public static String gb2iso(String str) {
if (MyUtils.isBlank(str)) {
return "";
}
String result = "";
try {
byte[] tmp = str.getBytes("GBK");
result = new String(tmp, "ISO8859_1");
} catch (UnsupportedEncodingException e) {
log.error("convert gb2iso error: ", e);
}
return result;
}
public static String gb2utf(String str) {
if (MyUtils.isBlank(str)) {
return "";
}
String result = "";
try {
byte[] tmp = str.getBytes("GBK");
result = new String(tmp, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.error("convert gb2utf error: ", e);
}
return result;
}
public static String iso2gb(String str) {
if (MyUtils.isBlank(str)) {
return "";
}
String result = "";
try {
byte[] tmp = str.getBytes("ISO8859_1");
result = new String(tmp, "GBK");
} catch (UnsupportedEncodingException e) {
log.error("convert iso2gb error: ", e);
}
return result;
}
public static String iso2utf(String str) {
if (MyUtils.isBlank(str)) {
return "";
}
String result = "";
try {
byte[] tmp = str.getBytes("ISO8859_1");
result = new String(tmp, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.error("convert iso2utf error: ", e);
}
return result;
}
public static String utf2gb(String str) {
if (MyUtils.isBlank(str)) {
return "";
}
String result = "";
try {
byte[] tmp = str.getBytes("UTF-8");
result = new String(tmp, "GBK");
} catch (UnsupportedEncodingException e) {
log.error("convert utf2gb error: ", e);
}
return result;
}
public static String utf2iso(String str) {
if (MyUtils.isBlank(str)) {
return "";
}
String result = "";
try {
byte[] tmp = str.getBytes("UTF-8");
result = new String(tmp, "ISO8859_1");
} catch (UnsupportedEncodingException e) {
log.error("convert utf2iso error: ", e);
}
return result;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -