Created
May 11, 2014 02:21
-
-
Save loufq/9545f3801d82643c0879 to your computer and use it in GitHub Desktop.
C# fetch js page convert utf82string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string Unicode2Chinese(string strUnicode) | |
{ | |
string[] splitString = new string[1]; | |
splitString[0] = "\\u"; | |
string[] unicodeArray = strUnicode.Split(splitString, StringSplitOptions.RemoveEmptyEntries); | |
StringBuilder sb = new StringBuilder(); | |
foreach (string item in unicodeArray) | |
{ | |
byte[] codes = new byte[2]; | |
int code1, code2; | |
code1 = Convert.ToInt32(item.Substring(0, 2), 16); | |
code2 = Convert.ToInt32(item.Substring(2), 16); | |
codes[0] = (byte)code2;//必须是小端在前 | |
codes[1] = (byte)code1; | |
sb.Append(Encoding.Unicode.GetString(codes)); | |
} | |
return sb.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
出处