用正则分别解码字符串里可以解码的ASCII字符 |
/// <summary>
/// ASCII解码
/// </summary>
/// <param name="str">需要解码的字符串</param>
/// <returns></returns>
public static string ToAsciiIDecode(this string str)
{StringBuilder sb = new StringBuilder();int indexSatae = -1;foreach (Match i in new Regex(@"&#\d{1,5};").Matches(str)){string s = i.Value.Substring(2);if (indexSatae != -1){sb.Append(str.Substring(indexSatae, i.Index - indexSatae));}sb.Append((char)(s.Substring(0,s.Length-1).toInt()));indexSatae = i.Index + i.Length;}if (indexSatae != -1){sb.Append(str.Substring(indexSatae));}return sb.ToString();
}/// <summary>
/// 转换成Int类型
/// </summary>
/// <param name="str">需要转换的字符串</param>
/// <returns></returns>
public static int toInt(this string str)
{return int.Parse(str);
}
个人博客地址???????