Here's a small piece to bring you a C # to convert Unicode encoding into a Chinese character string simple method. Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.
C # will JS in the Unicode conversion to a string, the Internet is not looking for, encountered a number of the turn, slightly changed the point, OK!
Examples are as follows:
///converts Unicode encoding to Chinese character string///////Unicode encoded string//Chinese character string public static s Tring ToGB2312 (String str) {MatchCollection MC = regex.matches (str, "([\\w]+) | ( \\\\u ([\\w]{4})); if (MC! = NULL && MC. Count > 0) {StringBuilder sb = new StringBuilder (); foreach (Match m2 in MC) {string v = m2. Value; if (v.startswith ("\ \")) {string word = v.substring (2); Byte[] codes = new byte[2]; int code = CONVERT.TOINT32 (Word. Substring (0, 2), 16); int code2 = Convert.ToInt32 (Word. Substring (2), 16); Codes[0] = (byte) code2; CODES[1] = (byte) code; Sb. Append (Encoding.Unicode.GetString (codes)); } else {sb. Append (v); }} return sb. ToString (); } else {return str; } }