62,041
社区成员
发帖
与我相关
我的任务
分享
if (!new WebCommon().IsGB2312(Request["word"]))
word = HttpUtility.UrlDecode(Request["word"], System.Text.Encoding.GetEncoding("GB2312"));
else
word = Server.UrlDecode(Request["word"]);
Request.ServerVariables["QUERY_STRING"]
word = HttpUtility.UrlDecode(Request["word"], System.Text.Encoding.GetEncoding("UTF-8"));
/// <summary>
/// 判断是否为GB2312编码格式
/// </summary>
/// <param name="word"></param>
/// <returns></returns>
public bool IsGB2312(string word)
{
byte[] bytes = Encoding.GetEncoding("GB2312").GetBytes(word);
if (bytes.Length <= 1)
{
return false;
}
else
{
byte byte1 = bytes[0];
byte byte2 = bytes[1];
if (byte1 >= 176 && byte1 <= 247 && byte2 >= 160 && byte2 <= 254) //判断是否是GB2312
{
return false;
}
else
{
return true;
}
}
}