1. Baidu coding and decoding
Enter "Peng Chenggang" in Baidu and click "% C5 % ed % B3 % C9 % B8 % D5" in the URL bar after the search. How is this encoded, how to decode. the following two paragraphsCodeThese two questions can be solved:
// Baidu code
Console. writeline (system. Web. httputility. urlencode ("Peng Chenggang", system. Text. unicodeencoding. getencoding ("gb2312"). toupper ());
// Baidu Decoding
Console. writeline (system. web. httputility. urldecode ("% C5 % ed % B3 % C9 % B8 % D5", system. text. unicodeencoding. getencoding ("gb2312 ")));
2. html encoding and decoding Functions
// Html Encoding
System. Web. httputility. htmlencode (string); server. htmlencode (string)
// HTML Decoding
System. Web. httputility. htmldecode (string); server. htmldecode (string)
Decoding HTML tags. Non-HTML tags are not decoded, for example
--->
3. url encoding and decoding
// URL Encoding
System. Web. httputility. urlencode (string); server. urlencode (string );
System. Web. httputility. urlpathencode (string); server. urlpathencode (string );
Urlencode and urlpathencode are different in terms of encoding.
For example, urlencode encodes the entire URL (http://www.zzcn.net/full code)
Urlpathencode encode the content after http: // (www.zzcn.net)
// URL Decoding
System. Web. httputility. urldecode (string); server. urldecode (string );
4. UTF-8, gb2312 Conversion
UTF-8> gb2312
String content = "Peng Chenggang ";
Byte [] conby = encoding. utf8.getbytes (content );
Content = encoding. getencoding ("gb2312"). getstring (conby );
Console. writeline (content );
I will not write it on the contrary. I hope to have a better understanding of you. If you have any questions, please correct them. Thank you.