<pre name= "code" class= "java" >/** * <DL> * <DT><B> function Description </B></DT> * Full half-width of strings * </dl > * @author Hailan */public class Sbcchange {//public static void main (string[] args) {////string qjstr = "full-width turning half-angle DAO Zhe 4 ";//system.out.println (Qjstr.length () +" =length "),//qjstr.replaceall (" [] "," ");//system.out.println (QJstr.length () + "=replacelengthr");//string todbcres = Todbc (QJSTR);//system.out.println (Qjstr + "\ndb" + todbcres);////String Qbres = Bqchange (qjstr)//system.out.println (qjstr + "\NBQ" + qbres)//}//half-width to full-width/** * <b> function Description </b> * Half-width Chinese character to full-width kanji * @param qjstr Half-width * @return Full-width String * <p> * <b> Example:</b><br> * Use example Description * String a = Bqchange ("Approval") * </p> */public static Final String bqchange (string qjstr) {String outstr = ""; String tstr = ""; byte[] b = null;for (int i = 0; I < qjstr.length (); i++) {try {tstr = qjstr.substring (i, i + 1); b = Tstr.getbytes ("Unicode");} catch (Java.io.UnsupportedEncodingException e) {E.prinTstacktrace ();} if (b[3]! =-1) {b[2] = (byte) (b[2]-+); B[3] = -1;try {outstr = outstr + new String (b, "Unicode");} catch (Java.io.Unsu Pportedencodingexception e) {e.printstacktrace ();}} Elseoutstr = Outstr + tstr;} return outstr;} /** * <b> Function Description </b> * Full-width Turn half-width * @param input full-width String * @return * <p> * <b> Example:</b><br> * Use example Child Description * String a = Todbc ("Re") * </p> */public static String todbc (string input) {char[] c = Input.tochararray (); for ( int i = 0; i < c.length; i++) {if (c[i] = = 12288) {C[i] = (char) 32;continue;} if (C[i] > 65280 && c[i] < 65375) C[i] = (char) (C[i]-65248);} return new String (c);}}
[Java] Full half-width cross-turn of strings