java 字串處理 全形轉半形,半形轉換全形

2021-06-08 22:04:09 字數 924 閱讀 2310

第一種方法:

/*** 特殊字串轉換

* @class name fullcharconverter

* @author v-jiangwei

* @create in 2012-8-24

*/public class fullcharconverter // end for.

return outstrbuf.tostring();}}

return outstrbuf.tostring();

}/**

* @methods name main

* @create in 2012-8-24 by v-jiangwei

* @param args

*            void

*/public static void main(string args)

}第二種方法:

/*** 半形轉全形

* @param input string.

* @return 全形字串.

*/public static string tosbc(string input) else if (c[i] < '\177')

}return new string(c);

}/**

* 全形轉半形

* @param input string.

* @return 半形字串

*/ public static string todbc(string input) else if (c[i] > '\uff00' && c[i] < '\uff5f')

}string returnstring = new string(c);

return returnstring;

}public static void main(string args)

java 全形字符轉半形字元

專案中正好要用到全半形字元互轉,收藏下以後備用 public class test 全形空格為12288,半形空格為32 其他字元半形 33 126 與全形 65281 65374 的對應關係是 均相差65248 將字串中的全形字符轉為半形 param src 要轉換的包含全形的任意字串 retur...

全形轉半形,半形轉全形,判斷字元是否為全形

全形轉半形的函式 dbc case 任意字串 半形字串 全形空格為12288,半形空格為32 其他字元半形 33 126 與全形 65281 65374 的對應關係是 均相差65248 public string todbc string input if c i 65280 c i 65375 c...

java常用工具類 全形轉半形 半形轉全形

全形轉半形 半形轉全形 提供對字串的全形 半形,半形 全形轉換 codingwhy.com public class bcconvert stringbuilder buf new stringbuilder src.length char ca src.tochararray for int i ...