Public class charcodeutils {Private Static charsetconverter cc = new charsetconverter (10); Private Static logger = logger. getlogger (charcodeutils. class); Private Static Boolean hasinit = false;/*** get the configuration file path string [] ** @ return **/Private Static string getfileloc () throws domainexception {string filepath = ""; try {java.net. URL classurl = charcodeutils. class. getresource (""); filepath = classu RL. getpath ();} catch (exception e) {logger. Error ("An error occurred while obtaining the absolute path of the charmap file! ");} Logger.info (" filepath is: "+ filepath); If (filepath. indexof (". Jar ")! =-1) {string jarfile = filepath. tostring (). substring (5, filepath. tostring (). length ()-24); logger.info ("jarfile is:" + jarfile); try {jarfile1_jfo = new jarfile1_( jarfile); Return jfo. extrafiletopath ();} catch (exception e) {logger. error ("An error occurred while extracting the jar package! ", E); throw new domainexception (" can't get charmap file from jar: "+ jarfile) ;}} else {return filepath. tostring (). substring (0, filepath. tostring (). length ()-22) + "charmap" ;}}/*** initialize charcodeutils and load the corresponding encoding configuration file void **/Private Static void Init () throws domainexception {If (! Hasinit) {string Path = getfileloc () + file. separator; CC. setfiles (New String [] {path + "uct2s. CTB ", // convert traditional to simplified path +" ucs2t. CTB ", // simplified to traditional path +" ucsbc2dbc. CTB ", // convert the full-width to the half-width null, null, path +" ucint2ext. CTB ", path +" ucrglt. CTB ", path +" ucphrase. CTB ",}); CC. init (); hasinit = true; }}/ *** traditional to simplified void ** @ Param orstring **/public static string T2S (string orstring) throws domainexception {Init (); Return CC. map (0, orstring);}/*** simplified to traditional void ** @ Param orstring **/public static string s2t (string orstring) throws domainexception {Init (); return CC. map (1, orstring);}/*** fullwidth to halfwidth void ** @ Param orstring **/public static string w2h (string orstring) throws domainexception {Init (); return CC. map (2, orstring);}/*** string used by stringutils ** @ Param orstring * @ return * @ throws domainexception **/public static String qbchange (string orstring) throws domainexception {Init (); // logger.info ("qbchange:" + orstring); Return CC. map (2, CC. map (0, orstring);}/*** convert special symbol ** @ Param Str * @ return */public static string changess (string Str) {STR = stringutils. replace (STR, "'", "·"); STR = stringutils. replace (STR, "'", "'"); STR = stringutils. replace (STR, "\" "," "); STR = stringutils. replace (STR, "); STR = stri Ngutils. Replace (STR, ";", ";"); STR = stringutils. Replace (STR ,".",". "); STR = stringutils. Replace (STR,": ",": "); STR = stringutils. Replace (STR ,"? ","? "); STR = stringutils. Replace (STR ,"! ","! "); STR = stringutils. replace (STR, "\", "\"); STR = stringutils. replace (STR, "<", "<"); STR = stringutils. replace (STR, ">", ">"); Return STR ;} /*** main method void *** @ Param argz **/public static void main (string [] argz) throws domainexception {qbchange ("ABC ");}}