網(wǎng)址中的中文被轉(zhuǎn)碼的問題, 要跟原來網(wǎng)址對(duì)比只能通過轉(zhuǎn)碼來比較: static System.Text.StringBuilder _sb = new System.Text.StringBuilder(); public static string UrlEncode(string url) { _sb.Length = 0; if (string.IsNullOrEmpty(url) == false) { byte[] bs = System.Text.Encoding.UTF8.GetBytes(url); for(int i = 0; i < bs.Length; i++) { if(bs[i] < 128) { _sb.Append((char)bs[i]); } else { _sb.Append("%" + bs[i++].ToString("x").PadLeft(2, '0')); _sb.Append("%" + bs[i].ToString("x").PadLeft(2, '0')); } } } return _sb.ToString(); } |
|