?? chinese.java~4~
字號:
package com.tool;
import java.io.*;
//中文字符級轉換
public class Chinese {
public static String toUnicode(String strvalue) {
try {
if (strvalue == null) {
return null;
}
else {
strvalue = new String(strvalue.getBytes("GBK"), "ISO8859_1");
return strvalue;
}
}
catch (Exception e) {
return "";
}
}
//對輸入的字符串進行一次編碼轉換,防止SQL注入
public static String StringtoSql(String str) {
str = nullToString(str, "");
try {
str = str.trim().replace('\'', (char) 1);
}
catch (Exception e) {
return "";
}
return str;
}
//處理字符串中的空值
public static final String nullToString(String v, String toV) {
if (v == null) {
v = toV;
}
return v;
}
public static String toChinese(String strvalue) {
try {
if (strvalue == null) {
return "";
}
else {
strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK");
return strvalue;
}
}
catch (Exception e) {
return "";
}
}
public static String chinese(String a) {
try {
return new String(a.getBytes("ISO-8859-1"));
}
catch (UnsupportedEncodingException ex) {
return null;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -