标签:c style class blog code java
package com.sogou.html; public class FullHalfReverse { /** * 半角转全角 */ public static String ToSBC(String input) { char[] c = input.toCharArray(); int length=c.length; for (int i = 0; i < length; i++) { if (c[i] == ‘ ‘) { c[i] = ‘\u3000‘; } else if (c[i] < ‘\177‘) { c[i] = (char) (c[i] + 65248); } } return new String(c); } /** * 全角转半角 */ public static String ToDBC(String input){ char[] c=input.toCharArray(); int length=c.length; for(int i=0;i<length;i++){ if(c[i]==‘\u3000‘){ c[i]=‘ ‘; }else if(c[i]>‘\uFF00‘&&c[i]<‘\uFF5F‘){ c[i]=(char)(c[i]-65248); } } return new String(c); } }
标签:c style class blog code java
原文地址:http://www.cnblogs.com/csxf/p/3768499.html