Import org.apache.log4j.logger;
public class ConvertCoding {static Logger log = Logger.getLogger (ConvertCoding.class); public static String gb2unicode (final String gbkstr) {try {String tmp; StringBuffer sb = new StringBuffer (500); char c; int i, j; sb .SETLENGTH (0); for (i = 0; i 255) {j = (c >>> 8); TMP = INTEGER.TOHEXSTRING (j); if (Tmp.Length () == 1) sb.append ("0"); sb.append (tmp); j = (c & 0xff); tmp = integer.tohexstring (j ); If (tmp.Length () == 1) sb.append ("0"); sb.append (tmp);} else {sb.append ("00" integer.tohexstring (c));}} Return new string (sb) .touppercase ();} catch (exception e) {E.PrintStackTRA CE (); return "";} public static string unicode2GB (Final String Datastr) {Try {Int TotalNum = Datastr.Length (); if (Totalnum% 4! = 0) {Throw new Exception ("non-eligible Unicode code! ");} StringBuffer buffer = new stringbuffer (); string charStr ="; char letter = '; for (int i = 0; i