Java Chinese Identification Problem Full Solution [Second]

xiaoxiao2021-03-06  121

Copyright belongs to Shi Xiang (Elpha (AT) MSN (Dot) Com) All; Contact: MSN: Ealpha (AT) MSN (Dot) Com QQ: 9690501

============================================================================================================================================================================================================= ============================

The last article wrote an article, saying Chinese solutions, this article is doing a small finishing,

============================================================================================================================================================================================================= ============================

Subject with the previous article, and Chinese issues into a class, convenient for everyone to call

/ * Function: Public String GB (String Str) * Features: Output of the string in GB2312, solve the Chinese status garbled * / Import java.io.unsupportedEncodingexception; public class GB2312 {public GB2312 () {} // ---- ----- Output Chinese ----------------------------------------- Public STRING GB2312 (String S1 = NULL; if (Str == NULL) S1 = NULL; ELSE TRY {/ ** * Converts the string STR and gives the final value to S1 * / Byte [] TMPBYTE = Str.getbytes ("ISO8859_1"); S1 = new string (tmpByte);} catch (unsupporteencodingexception) {} return s1;} // ------------- Chinese internal code - ---------------------------------------------- Public String tochinese String strign) {try {if (strValue == null) Return null; else {strval = new string (Strigue.getbytes ("GB2312"), "GBK"); Return Strvalue;}} Catch (Exception E) {Return Null;}} // ----------- Output Chinese Public Static String DatabaseTochinese (String Strvalue) {Try {if (Strvalue == NULL) Return NULL; Else {Strvalue = New String (Strvalue.getBytes ("ISO-8859-1"), "GB2312"); Return Strvalue;}} Catch (Exception E) {Return NULL;

转载请注明原文地址:https://www.9cbs.com/read-127095.html

New Post(0)