The keyword encoding of Google and Baidu is different. It seems that Google is UTF-8 and Baidu is gb2312. There are many methods to solve the encoding. The following three methods are listed:
Uri. unescapedatastring (); It can be used to decode most of Google's Chinese keywords, but encoding that cannot be decoded will cause garbled characters and cannot be used to decrypt hundreds of keywords.
Microsoft. JScript. globalobject. decodeuri (); Most of the Chinese keywords can be decoded, but a small number of Chinese keywords cannot be decoded. Microsoft. JScript references are required.
Httputility. urldecode (STR, encoding. Default ); You can extract hundred-degree keyword encoding. you can decode the above two methods and cannot decode the Google Keyword. The system. Web reference is required.
To solve the problem of Google and Baidu keyword decoding simultaneously, you can use the following methods:
// STR is the encoded Google or Baidu keyword
Try
{
... Microsoft. JScript. globalobject. decodeuri (Str. Trim ())...
}
Catch {
... Httputility. urldecode (STR, encoding. Default )...
}
When Microsoft. JScript. globalobject. decodeuri () cannot be decoded, an error is returned. After capturing the error, you can use httputility. urldecode to decode it.