Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How does c# winform convert Chinese into%+letters+numbers? Like the keywords in Baidu search, Chinese keywords are divided into%+letters+numbers.
How does c# winform convert Chinese into%+letters+numbers? Like the keywords in Baidu search, Chinese keywords are divided into%+letters+numbers.
This is a url encoding format, except for a-Z, A-Z, 0-9 and? & amp! Some symbols, such as other characters, must be passed in the url in encoded form, and the format is%+two binary digits representing one byte. The character encoding used by Baidu is GBK, and most other websites use UTF-8. You can use the functions of the system. Web.httputility.urlencode () gets the encoded string (you need to add a reference to the system. Web first, selected. NET Framework cannot be a client profile):

var encodeString = System。 Web.HttpUtility.UrlEncode(str,Encoding。 GetEncode(" gbk "));

If it is UTF-8 encoding, you can also use system. uri.escapedatastring (str)。