Today, I spent a long time performing URI encoding and decoding operations. But I cannot get the desired result.
So I have referenced a lot Article , Two articles are recommended here:
Http://www.cnblogs.com/tishifu/archive/2006/03/01/340646.html
Http://www.cnblogs.com/TianFang/archive/2006/07/28/399842.html
Finally, based on the second article, I found a solution.
First, add a reference to system. Web. You may need to import system. Web. dll twice. Program Add a namespace reference to the set.
Next, refer to the following Code : 1 String Str1 = Textbox1.text;
2 String Str2 = System. Web. httputility. urlencode (str1, encoding. getencoding ( " Gb2312 " )); // Encode the string.
3 // String str2 = system. Web. httputility. urldecode (str1, encoding. getencoding ("gb2312 "));
4 // The preceding line of code is used to decode the URI-encoded string.
5 Textboxr. appendtext (str2 );
currently, I only know one of the above methods to correctly encode and decode them.
if you are not convinced, please try it. (the following URL provides the desired decoding and encoding results. For example, "new concept", the encoding I want is "% D0 % C2 % B8 % C5 % c4 % ee ").
http://www.haokucn.com/haocoolfj/onlinetools/aspcodetools/URLCode/URLDecoding.asp