/**
* 全角字符串转半角字符串,比如“(”--->"("
*/
public static String full2HalfWidth(String str) {
String outStr = "";
String Tstr = "";
byte[] b = null;
if ( str != null ) {
for (int i = 0; i < str.trim().length(); i++) {
try {
Tstr = str.substring(i, i + 1);
b = Tstr.getBytes("unicode");
} catch (java.io.UnsupportedEncodingException e) {
e.printStackTrace();
}
if ( b[2] == -1 ) {
b[3] = (byte)(b[3] + 32);
b[2] = 0;
try {
outStr = outStr + new String(b, "unicode");
} catch (java.io.UnsupportedEncodingException e) {
e.printStackTrace();
}
} else {
outStr = outStr + Tstr;
}
}
}
return outStr;
}
/**
* 半角字符转成全角字符串,比如"("--->"("
*/
public static String half2FullWidth(String str) {
String outStr = "";
String Tstr = "";
byte[] b = null;
if ( str != null ) {
for (int i = 0; i < str.trim().length(); i++) {
try {
Tstr = str.substring(i, i + 1);
b = Tstr.getBytes("unicode");
} catch (java.io.UnsupportedEncodingException e) {
e.printStackTrace();
}
if ( b[2] == 0 ) {
b[3] = (byte)(b[2] - 32);
b[2] = -1;
try {
outStr = outStr + new String(b, "unicode");
} catch (java.io.UnsupportedEncodingException e) {
e.printStackTrace();
}
} else {
outStr = outStr + Tstr;
}
}
}
return outStr;
}
* 全角字符串转半角字符串,比如“(”--->"("
*/
public static String full2HalfWidth(String str) {
String outStr = "";
String Tstr = "";
byte[] b = null;
if ( str != null ) {
for (int i = 0; i < str.trim().length(); i++) {
try {
Tstr = str.substring(i, i + 1);
b = Tstr.getBytes("unicode");
} catch (java.io.UnsupportedEncodingException e) {
e.printStackTrace();
}
if ( b[2] == -1 ) {
b[3] = (byte)(b[3] + 32);
b[2] = 0;
try {
outStr = outStr + new String(b, "unicode");
} catch (java.io.UnsupportedEncodingException e) {
e.printStackTrace();
}
} else {
outStr = outStr + Tstr;
}
}
}
return outStr;
}
/**
* 半角字符转成全角字符串,比如"("--->"("
*/
public static String half2FullWidth(String str) {
String outStr = "";
String Tstr = "";
byte[] b = null;
if ( str != null ) {
for (int i = 0; i < str.trim().length(); i++) {
try {
Tstr = str.substring(i, i + 1);
b = Tstr.getBytes("unicode");
} catch (java.io.UnsupportedEncodingException e) {
e.printStackTrace();
}
if ( b[2] == 0 ) {
b[3] = (byte)(b[2] - 32);
b[2] = -1;
try {
outStr = outStr + new String(b, "unicode");
} catch (java.io.UnsupportedEncodingException e) {
e.printStackTrace();
}
} else {
outStr = outStr + Tstr;
}
}
}
return outStr;
}