Como mostrado abaixo:
pacote test.com.gjob.services; importar java.util.properties; classe pública teste {public static void main (string [] args) {string s = "Introdução"; String tt = gBencoding (s); // string tt1 = "Olá, eu quero te dizer uma coisa"; System.out.println (decodeunicode ("// u7b80 // u4ecb")); // system.out.println (decodeunicode (tt1)); System.out.println (htmldecoder.decode ("China")); String s1 = "/u7b80/u4ecb"; System.out.println (s.IndexOF ("//")); } public static string gbencoding (string final gbString) {char [] utfbytes = gbString.toCharArray (); String unicodeBytes = ""; for (int byteIndex = 0; byteIndex <utfbytes.length; byteIndex ++) {string hexb = intoHexString (utfbytes [byteIndex]); if (hexb.length () <= 2) {hexb = "00" + hexb; } unicodeBytes = unicodeBytes + "// u" + hexb; } System.out.println ("UnicodeBytes é:" + unicodeBytes); retornar unicodebytes; } public static string decodeunicode (datast de string final) {int start = 0; int end = 0; final StringBuffer buffer = new StringBuffer (); while (start> -1) {end = datast.indexof ("// u", start + 2); String charstr = ""; if (end == -1) {charstr = datastr.substring (start + 2, datastr.length ()); } else {charstr = datastr.substring (start + 2, end); } char letter = (char) Integer.parseint (Charstr, 16); // Subia de modelagem de plástico de análise hexadecimal. buffer.append (novo personagem (letra) .toString ()); start = end; } retornar buffer.toString (); }} public static string decodeunicode (string thestring) {char achar; int len = thestring.length (); Stringbuffer outbuffer = new StringBuffer (len); for (int x = 0; x <len;) {achar = theString.charat (x ++); if (achar == '//') {achar = thestring.charat (x ++); if (achar == 'u') {// leia o xxxx int value = 0; for (int i = 0; i <4; i ++) {achar = theString.charat (x ++); switch (achar) {case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': value = (valor << 4) + achar - '0'; quebrar; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': value = (valor << 4) + 10 + achar - 'a'; quebrar; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': value = (valor << 4) + 10 + achar - 'a'; quebrar; Padrão: jogue novo ilegalargumentException ("codificação malformada // uxxxx"); }} outbuffer.append ((char) valor); } else {if (achar == 't') achar = '/t'; caso contrário, se (achar == 'r') achar = '/r'; caso contrário, se (achar == 'n') achar = '/n'; caso contrário, se (achar == 'n') achar = '/n'; caso contrário, se (achar == 'f') achar = '/f'; outbuffer.append (achar); }} else outbuffer.append (achar); } retornar outBuffer.toString (); }A simples implementação da conversão do Unicode e da China em Java no artigo acima é todo o conteúdo que compartilho com você. Espero que você possa lhe dar uma referência e espero que você possa apoiar mais o wulin.com.