输入为带有urldecode转码文本,输出正常文本。
//20130625 by zhangyl
private string ConvertToString(string input)
{
input = input.Replace("\\\"", "\"");
input = input.Replace("\\/", "/");
string result;
if (!input.Contains("\\u"))
{
result = input;
}
else
{
StringBuilder stringBuilder = new StringBuilder();
if (input.IndexOf("\\u") > )
{
stringBuilder.Append(input.Substring(, input.IndexOf("\\u")));
input = input.Substring(input.IndexOf("\\u"));
}
if (!string.IsNullOrEmpty(input))
{
string[] array = input.Split(new string[]
{
"\\u"
}, StringSplitOptions.RemoveEmptyEntries);
string[] array2 = array;
for (int i = ; i < array2.Length; i++)
{
string text = array2[i];
if (text.Length > )
{
string arg = text.Substring();
stringBuilder.Append((char)int.Parse(text.Substring(, ), NumberStyles.HexNumber) + arg);
}
else
{
if (text.Length == )
{
stringBuilder.Append((char)int.Parse(text, NumberStyles.HexNumber));
}
else
{
if (text.Length < && text.Length > )
{
stringBuilder.Append(text);
}
}
}
}
}
result = stringBuilder.ToString();
}
return result;
}