Skip to content

Instantly share code, notes, and snippets.

@loufq
Created May 11, 2014 02:21
Show Gist options
  • Save loufq/9545f3801d82643c0879 to your computer and use it in GitHub Desktop.
Save loufq/9545f3801d82643c0879 to your computer and use it in GitHub Desktop.
C# fetch js page convert utf82string
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();
}
@loufq
Copy link
Author

loufq commented May 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment