About URL decoding, encoding

Source: Internet
Author: User
<span id="Label3"></p> <ul> <ul> <li>Because of the recent customer need to use CA certification, This CA certification is the URL method of the value of the pass-through</li> </ul> </ul><p><p><span style="font-family: 宋体; font-size: 12pt;">Converts a URL-encoded string to a decoded string using the specified encoding Object.</span></p></p> <ul> <ul> <li><span style="font-family: 宋体; font-size: 12pt;">Encoding a Person's understanding is to store a string in some way, while decoding the correct result in its encoded format</span></li> <li><span style="font-family: 宋体; font-size: 12pt;">General Coding Keywords</span> <span style="color: red; font-family: 新宋体; font-size: 9pt;">Encoding</span> <span style="font-family: 宋体; font-size: 12pt;">introduce a namespace:</span> <span style="color: black; font-family: 新宋体; font-size: 9pt;">System.Text</span></li> <li><span style="font-family: 宋体; font-size: 12pt;"><strong>URL encoding introduces Namespaces:</strong> <span style="color: blue; text-decoration: underline;">system.web</span><br><strong>assemblies:</strong> System.Web (in System.Web.dll)<br></span></li> <li><span style="font-family: 宋体; font-size: 12pt;"><strong>URL encoding</strong></span></li> </ul> </ul> <table style="border-collapse: collapse; background: #deeaf6;" border="0"> <colgroup> <col style="width:329px" , "> <col style=" width:320px; "> <col style=" width:321px; "> <col style=" width: 318px; "> </colgroup> <tbody valign="top"> <tr style="height: 27px;"> <td style="padding-left:7px; padding-right:7px; border:solid 0.5pt;"><p style=" text-align:center; "><span style="color:red;"> name </span> </p> </td> <td style="padding-left:7px; padding-right:7px; Border-top:solid 0.5pt; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"><span style="color:red;" "description < span> </span></p> </td> <td style=" padding-left:7px; padding-right:7px; Border-top:solid 0.5pt; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"><span style="color:red;"> return value </span> </p> </td> <td style="padding-left:7px; padding-right:7px; Border-top:solid 0.5pt; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"><span style="color:red;" "instance < span> </span></p> </td> </tr> <tr style="height: 25px;"> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:solid 0.5pt; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "> <p> <span style="color:black; font-family: New song body; font-size:9pt; >urlencode (<span style=" color: #2b91af; ">byte <span style="color:black;">[]) </span> </span> </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"><span style="color:black; font-family: New song body; font-size:9pt;"> convert byte arrays to encoded URLs String. </span> </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"> a coded string. </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; ">  </td> </tr> <tr style="height: 27px;"> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:solid 0.5pt; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "> <p> <span style="color:black; font-family: New song body; font-size:9pt; >urlencode (<span style=" color: #2b91af; "> String a<span style="color:black;">) </span> </span> </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"><span style="color:black; font-family: New song body; font-size:9pt;"> encode URL strings </span> </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"> a coded string. </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; ">  </td> </tr> <tr style="height: 25px;"> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: solid 0.5pt; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p><span style="color: black; font-family: 新宋体; font-size: 9pt;">UrlEncode (<span style="color: #2b91af;">String<span style="color: black;">, <span style="color: #2b91af;">Encoding <span style="color: black;">)</span> </span> </span> </span></span></p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p style="text-align: center;"><span style="color: black; font-family: 新宋体; font-size: 9pt;">Encodes a URL string using the specified encoding Object.</span></p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p style="text-align: center;">A string that has been encoded.</p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p><span style="color: #2b91af; font-family: 新宋体; font-size: 9pt;">HttpUtility<span style="color: black;">. UrlEncode (string, <span style="color: #2b91af;">Encoding<span style="color: black;">. GetEncoding (<span style="color: #a31515;">"GB2312"<span style="color: black;">));//encode The string in GB2312 way</span> </span> </span> </span> </span></span></p></td> </tr> <tr style="height: 5px;"> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: solid 0.5pt; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p><span style="color: black; font-family: 新宋体; font-size: 9pt;">UrlEncode (<span style="color: #2b91af;">Byte<span style="color: black;">[], <span style="color: #2b91af;">Int32<span style="color: black;">, <span style="color: #2b91af;">Int32<span style="color: black;">)</span> </span> </span> </span> </span> </span></span></p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p style="text-align: center;"><span style="color: black; font-family: 新宋体; font-size: 9pt;">Converts a byte array to a URL-encoded string, starting at the specified position of the array and ending with the specified number of Bytes.</span></p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p style="text-align: center;">A string that has been encoded.</p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"></td> </tr> </tbody> </table> <ul> <ul> <li><span style="font-family: 宋体; font-size: 12pt;"><strong>Corresponds to the above URL decoding</strong></span></li> </ul> </ul> <table style="border-collapse: collapse; background: #deeaf6;" border="0"> <colgroup> <col style="width: 329px;"> <col style="width: 320px;"> <col style="width: 321px;"> <col style="width: 318px;"> </colgroup> <tbody valign="top"> <tr style="height: 27px;"> <td style="padding-left:7px; padding-right:7px; border:solid 0.5pt;"><p style=" text-align:center; "><span style="color:red;"> name </span> </p> </td> <td style="padding-left:7px; padding-right:7px; Border-top:solid 0.5pt; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"><span style="color:red;" "description < span> </span></p> </td> <td style=" padding-left:7px; padding-right:7px; Border-top:solid 0.5pt; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"><span style="color:red;"> return value </span> </p> </td> <td style="padding-left:7px; padding-right:7px; Border-top:solid 0.5pt; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"><span style="color:red;" "instance < span> </span></p> </td> </tr> <tr style="height: 25px;"> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:solid 0.5pt; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "> <p> <span style="color:black; font-family: New song body; font-size:9pt; >urldecode (<span style=" color: #2b91af; ">byte <span style="color:black;">[]) </span> </span> </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"><span style="color:black; font-family: New song body; font-size:9pt;"> convert byte arrays to encoded URLs String. </span> </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"> a coded string. </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; ">  </td> </tr> <tr style="height: 27px;"> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:solid 0.5pt; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "> <p> <span style="color:black; font-family: New song body; font-size:9pt; >urldecode (<span style=" color: #2b91af; "> String a<span style="color:black;">) </span> </span> </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"><span style="color:black; font-family: New song body; font-size:9pt;"> encode URL strings </span> </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; "><p style="text-align:center;"> a coded string. </p> </td> <td style="padding-left:7px; padding-right:7px; border-top:none; border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt; ">  </td> </tr> <tr style="height: 25px;"> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: solid 0.5pt; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p><span style="color: black; font-family: 新宋体; font-size: 9pt;">UrlDecode (<span style="color: #2b91af;">String<span style="color: black;">, <span style="color: #2b91af;">Encoding <span style="color: black;">)</span> </span> </span> </span></span></p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p style="text-align: center;"><span style="color: black; font-family: 新宋体; font-size: 9pt;">Encodes a URL string using the specified encoding Object.</span></p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p style="text-align: center;">A string that has been encoded.</p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p><span style="color: #2b91af; font-family: 新宋体; font-size: 9pt;">HttpUtility<span style="color: black;">. UrlDecode (string, <span style="color: #2b91af;">Encoding<span style="color: black;">. GetEncoding (<span style="color: #a31515;">"GB2312"<span style="color: black;">));//decoding A string in GB2312 way</span> </span> </span> </span> </span></span></p></td> </tr> <tr style="height: 5px;"> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: solid 0.5pt; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p><span style="color: black; font-family: 新宋体; font-size: 9pt;">UrlDecode (<span style="color: #2b91af;">Byte<span style="color: black;">[], <span style="color: #2b91af;">Int32<span style="color: black;">, <span style="color: #2b91af;">Int32<span style="color: black;">)</span> </span> </span> </span> </span> </span></span></p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p style="text-align: center;"><span style="color: black; font-family: 新宋体; font-size: 9pt;">Converts a byte array to a URL-encoded string, starting at the specified position of the array and ending with the specified number of Bytes.</span></p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"><p style="text-align: center;">A string that has been encoded.</p></td> <td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;"></td> </tr> </tbody> </table><p><p></p></p> <ol> <li><li><span style="font-size: 9pt;"><span style="color: blue;">string</span> str1 = System.Web.HttpUtility.UrlEncode (string, encoding.getencoding ("<span style="color: darkred;">GB2312</span>")); <span style="color: green;">//this is a string encoded with GB2312</span></span></li></li> <li><li></li></li> <li><li><span style="font-size: 9pt;"><span style="color: blue;">string</span> str_1 = System.Web.HttpUtility.UrlEncode (string, encoding.getencoding ("<span style="color: darkred;">utf-8</span>")); <span style="color: green;">//this is the UTF-8 encoding of the string</span></span></li></li> <li><li></li></li> <li><li><span style="font-size: 9pt;"><span style="color: blue;"></span> string str2= httputility.urldecode (string, encoding.getencoding ("<span style="color: darkred;">gb2312</span>")); <span style="color: green;">//this is a string encoded with GB2312</span></span></li></li> <li><li></li></li> <li><li><span style="font-size: 9pt;"><span style="color: blue;">string</span> str2 = Httputility.urldecode (string, encoding.getencoding ("<span style="color: darkred;">utf-8</span>")); <span style="color: green;">//this is a string encoded with UTF-8</span></span></li></li> </ol><p><p>The above collection refers to C # development documentation</p></p><p><p>About URL decoding, encoding</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.