{"id":269,"date":"2012-12-05T18:08:22","date_gmt":"2012-12-05T18:08:22","guid":{"rendered":"06138bc5af6023646ede0e1f7c1eac75"},"modified":"2012-12-05T18:08:22","modified_gmt":"2012-12-05T18:08:22","slug":"","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/269","title":{"rendered":"\u7b80\u5355\u4fee\u6539\u4f7fbase64\u9002\u7528url"},"content":{"rendered":"<p>\u6807\u51c6\u7684Base64\u5e76\u4e0d\u9002\u5408\u76f4\u63a5\u653e\u5728URL\u91cc\u4f20\u8f93\uff0c\u56e0\u4e3aURL\u7f16\u7801\u5668\u4f1a\u628a\u6807\u51c6Base64\u4e2d\u7684\u201c\/\u201d\u548c\u201c+\u201d<a href=\"http:\/\/baike.baidu.com\/view\/263416.htm\" target=\"_blank\"><span style=\"color:#136ec2;\">\u5b57\u7b26<\/span><\/a>\u53d8\u4e3a\u5f62\u5982\u201c%XX\u201d\u7684\u5f62\u5f0f\uff0c\u800c\u8fd9\u4e9b\u201c%\u201d\u53f7\u5728\u5b58\u5165\u6570\u636e\u5e93\u65f6\u8fd8\u9700\u8981\u518d\u8fdb\u884c\u8f6c\u6362\uff0c\u56e0\u4e3aANSI SQL\u4e2d\u5df2\u5c06\u201c%\u201d\u53f7\u7528\u4f5c<a href=\"http:\/\/baike.baidu.com\/view\/451.htm\" target=\"_blank\"><span style=\"color:#136ec2;\">\u901a\u914d\u7b26<\/span><\/a>\u3002 <\/p>\n<div class=\"spctrl\"><\/div>\n<p>\u3000\u3000\u4e3a\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u91c7\u7528\u4e00\u79cd\u7528\u4e8eURL\u7684\u6539\u8fdbBase64\u7f16\u7801\uff0c\u5b83\u4e0d\u5728\u672b\u5c3e\u586b\u5145'='\u53f7\uff0c\u5e76\u5c06\u6807\u51c6Base64\u4e2d\u7684\u201c+\u201d\u548c\u201c\/\u201d\u5206\u522b\u6539\u6210\u4e86\u201c*\u201d\u548c\u201c-\u201d\uff0c\u8fd9\u6837\u5c31\u514d\u53bb\u4e86\u5728URL\u7f16\u89e3\u7801\u548c\u6570\u636e\u5e93\u5b58\u50a8\u65f6\u6240\u8981\u4f5c\u7684\u8f6c\u6362\uff0c\u907f\u514d\u4e86\u7f16\u7801\u4fe1\u606f\u957f\u5ea6\u5728\u6b64\u8fc7\u7a0b\u4e2d\u7684\u589e\u52a0\uff0c\u5e76\u7edf\u4e00\u4e86\u6570\u636e\u5e93\u3001\u8868\u5355\u7b49\u5904\u5bf9\u8c61<a href=\"http:\/\/baike.baidu.com\/view\/390932.htm\" target=\"_blank\"><span style=\"color:#136ec2;\">\u6807\u8bc6\u7b26<\/span><\/a>\u7684\u683c\u5f0f\u3002 <\/p>\n<div class=\"spctrl\"><\/div>\n<p>\u3000\u3000\u53e6\u6709\u4e00\u79cd\u7528\u4e8e<a href=\"http:\/\/baike.baidu.com\/view\/94238.htm\" target=\"_blank\"><span style=\"color:#136ec2;\">\u6b63\u5219\u8868\u8fbe\u5f0f<\/span><\/a>\u7684\u6539\u8fdbBase64\u53d8\u79cd\uff0c\u5b83\u5c06\u201c+\u201d\u548c\u201c\/\u201d\u6539\u6210\u4e86\u201c!\u201d\u548c\u201c-\u201d\uff0c\u56e0\u4e3a\u201c+\u201d,\u201c*\u201d\u4ee5\u53ca\u524d\u9762\u5728IRCu\u4e2d\u7528\u5230\u7684\u201c[\u201d\u548c\u201c]\u201d\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u90fd\u53ef\u80fd\u5177\u6709\u7279\u6b8a\u542b\u4e49\u3002 <\/p>\n<div class=\"spctrl\"><\/div>\n<p>\u3000\u3000\u6b64\u5916\u8fd8\u6709\u4e00\u4e9b\u53d8\u79cd\uff0c\u5b83\u4eec\u5c06\u201c+\/\u201d\u6539\u4e3a\u201c_-\u201d\u6216\u201c._\u201d\uff08\u7528\u4f5c<a href=\"http:\/\/baike.baidu.com\/view\/552871.htm\" target=\"_blank\"><span style=\"color:#136ec2;\">\u7f16\u7a0b\u8bed\u8a00<\/span><\/a>\u4e2d\u7684<a href=\"http:\/\/baike.baidu.com\/view\/390932.htm\" target=\"_blank\"><span style=\"color:#136ec2;\">\u6807\u8bc6\u7b26<\/span><\/a>\u540d\u79f0\uff09\u6216\u201c.-\u201d\uff08\u7528\u4e8eXML\u4e2d\u7684Nmtoken\uff09\u751a\u81f3\u201c_:\u201d\uff08\u7528\u4e8eXML\u4e2d\u7684Name\uff09\u3002 <\/p>\n<p>&nbsp;<\/p>\n<div class=\"d\" sizset=\"74\" sizcache003828879618480158=\"82\"><!--[diy=diycontenttop]--><\/p>\n<div id=\"diycontenttop\" class=\"area\"><\/div>\n<p><!--[\/diy]--><\/p>\n<table class=\"vwtb\" cellspacing=\"0\" cellpadding=\"0\" sizset=\"6\" sizcache003828879618480158=\"1\">\n<tbody sizset=\"0\" sizcache003828879618480158=\"69\">\n<tr class=\" slvzr-hover\" sizset=\"6\" sizcache003828879618480158=\"1\">\n<td id=\"article_content\" sizset=\"6\" sizcache003828879618480158=\"1\"><!--  -->&nbsp;&nbsp;&nbsp; \u91c7\u7528 Base64 \u7f16\u7801\u4e0d\u4ec5\u6bd4\u8f83\u7b80\u77ed\uff0c\u540c\u65f6\u5177\u6709\u4e0d\u53ef\u8bfb\u6027\uff0c\u88ab\u7f16\u7801\u7684\u6570\u636e\u4e0d\u4f1a\u88ab\u4eba\u7528\u8089\u773c\u6240\u76f4\u63a5\u770b\u5230\u3002 \u4f46\u662f\uff0c\u6807\u51c6\u7684 Base64 \u5e76\u4e0d\u9002\u5408\u76f4\u63a5\u653e\u5728 URL \u91cc\u4f7f\u7528\uff0c\u56e0\u4e3aBase64\u4e2d\u542b\u6709'+' \u548c '\/'\uff0c URL \u7f16\u7801\u5668\u4f1a '+' \u548c '\/' \u53d8\u4e3a\u5f62\u5982 \"%XX\u201d \u7684\u5f62\u5f0f\u3002<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;\u4fee\u6539\u4e00\u4e0bBase64\u5c31\u53ef\u4ee5\u5728URL\u4e2d\u4f7f\u7528\u4e86\uff1a <\/p>\n<div class=\"cnblogs_code\" sizset=\"6\" sizcache003828879618480158=\"1\">\n<div sizset=\"6\" sizcache003828879618480158=\"1\"><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\">&nbsp;<\/span><span style=\"color:#808080;\">&lt;summary&gt;<\/span><span style=\"color:#008000;\"><br \/>\n<\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\">&nbsp;Base64&nbsp;\u8f6c\u6362&nbsp;UrlBase64\uff0c\u4f7f\u4e4b\u9002\u5408\u5728url\u4e2d\u4f7f\u7528<br \/>\n<\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\">&nbsp;<\/span><span style=\"color:#808080;\">&lt;\/summary&gt;<\/span><span style=\"color:#808080;\"><br \/>\n<\/span><span style=\"color:#0000ff;\">public<\/span>&nbsp;<span style=\"color:#0000ff;\">static<\/span>&nbsp;<span style=\"color:#0000ff;\">string<\/span>&nbsp;Base64ToUrlBase64(<span style=\"color:#0000ff;\">string<\/span>&nbsp;base64str)<br \/>\n{<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:#008000;\">\/\/<\/span><span style=\"color:#008000;\">&nbsp;\"+\"&nbsp;\u6362\u6210&nbsp;\"-A\"<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color:#008000;\">\/\/<\/span><span style=\"color:#008000;\">&nbsp;\"\/\"&nbsp;\u6362\u6210&nbsp;\"-S\"<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color:#008000;\">\/\/<\/span><span style=\"color:#008000;\">&nbsp;\u53bb\u6389&nbsp;\"=\"<\/span><span style=\"color:#008000;\"><br \/>\n<\/span>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:#0000ff;\">return<\/span>&nbsp;base64str.Replace(<span style=\"color:#800000;\">\"<\/span><span style=\"color:#800000;\">+<\/span><span style=\"color:#800000;\">\"<\/span>,&nbsp;<span style=\"color:#800000;\">\"<\/span><span style=\"color:#800000;\">-A<\/span><span style=\"color:#800000;\">\"<\/span>).Replace(<span style=\"color:#800000;\">\"<\/span><span style=\"color:#800000;\">\/<\/span><span style=\"color:#800000;\">\"<\/span>,&nbsp;<span style=\"color:#800000;\">\"<\/span><span style=\"color:#800000;\">-S<\/span><span style=\"color:#800000;\">\"<\/span>).Replace(<span style=\"color:#800000;\">\"<\/span><span style=\"color:#800000;\">=<\/span><span style=\"color:#800000;\">\"<\/span>,&nbsp;<span style=\"color:#0000ff;\">string<\/span>.Empty);<br \/>\n}<\/p>\n<p><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\">&nbsp;<\/span><span style=\"color:#808080;\">&lt;summary&gt;<\/span><span style=\"color:#008000;\"><br \/>\n<\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\">&nbsp;UrlBase64&nbsp;\u8f6c\u6362&nbsp;Base64<br \/>\n<\/span><span style=\"color:#808080;\">\/\/\/<\/span><span style=\"color:#008000;\">&nbsp;<\/span><span style=\"color:#808080;\">&lt;\/summary&gt;<\/span><span style=\"color:#808080;\"><br \/>\n<\/span><span style=\"color:#0000ff;\">public<\/span>&nbsp;<span style=\"color:#0000ff;\">static<\/span>&nbsp;<span style=\"color:#0000ff;\">string<\/span>&nbsp;UrlBase64ToBase64(<span style=\"color:#0000ff;\">string<\/span>&nbsp;urlBase64str)<br \/>\n{<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:#008000;\">\/\/<\/span><span style=\"color:#008000;\">&nbsp;\"-A\"&nbsp;\u6362\u6210&nbsp;\"+\"<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color:#008000;\">\/\/<\/span><span style=\"color:#008000;\">&nbsp;\"-S\"&nbsp;\u6362\u6210&nbsp;\"\/\"<\/span><span style=\"color:#008000;\"><br \/>\n<\/span>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:#0000ff;\">string<\/span>&nbsp;str&nbsp;=&nbsp;urlBase64str.Replace(<span style=\"color:#800000;\">\"<\/span><span style=\"color:#800000;\">-A<\/span><span style=\"color:#800000;\">\"<\/span>,&nbsp;<span style=\"color:#800000;\">\"<\/span><span style=\"color:#800000;\">+<\/span><span style=\"color:#800000;\">\"<\/span>).Replace(<span style=\"color:#800000;\">\"<\/span><span style=\"color:#800000;\">-S<\/span><span style=\"color:#800000;\">\"<\/span>,&nbsp;<span style=\"color:#800000;\">\"<\/span><span style=\"color:#800000;\">\/<\/span><span style=\"color:#800000;\">\"<\/span>);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:#008000;\">\/\/<\/span><span style=\"color:#008000;\">&nbsp;\u6dfb\u52a0\"=\"<\/span><span style=\"color:#008000;\"><br \/>\n<\/span>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:#0000ff;\">int<\/span>&nbsp;mod&nbsp;=&nbsp;str.Length&nbsp;%&nbsp;<span style=\"color:#800080;\">4<\/span>;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:#0000ff;\">if<\/span>&nbsp;(mod&nbsp;!=&nbsp;<span style=\"color:#800080;\">0<\/span>)<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;{<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str&nbsp;+=&nbsp;<span style=\"color:#0000ff;\">new<\/span>&nbsp;<span style=\"color:#0000ff;\">string<\/span>(<span style=\"color:#800000;\">'<\/span><span style=\"color:#800000;\">=<\/span><span style=\"color:#800000;\">'<\/span>,&nbsp;<span style=\"color:#800080;\">4<\/span>&nbsp;-&nbsp;mod);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:#0000ff;\">return<\/span>&nbsp;str;<br \/>\n}<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6807\u51c6\u7684Base64\u5e76\u4e0d\u9002\u5408\u76f4\u63a5\u653e\u5728URL\u91cc\u4f20\u8f93\uff0c\u56e0\u4e3aURL\u7f16\u7801\u5668\u4f1a\u628a\u6807\u51c6Base64\u4e2d\u7684\u201c\/\u201d\u548c\u201c+\u201d<a href=\"http:\/\/baike.baidu.com\/view\/263416.htm\" target=\"_blank\"><span style=\"color:#136ec2;\">\u5b57\u7b26<\/span><\/a>\u53d8\u4e3a\u5f62\u5982\u201c%XX\u201d\u7684\u5f62\u5f0f\uff0c\u800c\u8fd9\u4e9b\u201c%\u201d\u53f7\u5728\u5b58\u5165\u6570\u636e\u5e93\u65f6\u8fd8\u9700\u8981\u518d\u8fdb\u884c\u8f6c\u6362\uff0c\u56e0\u4e3aANSI SQL\u4e2d\u5df2\u5c06\u201c%\u201d\u53f7\u7528\u4f5c<a href=\"http:\/\/baike.baidu.com\/view\/451.htm\" target=\"_blank\"><span style=\"color:#136ec2;\">\u901a\u914d\u7b26<\/span><\/a>\u3002<br \/>\n\u3000\u3000\u4e3a\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u91c7\u7528\u4e00\u79cd\u7528\u4e8eURL\u7684\u6539\u8fdbBase64\u7f16\u7801\uff0c\u5b83\u4e0d\u5728\u672b\u5c3e\u586b\u5145'='\u53f7\uff0c\u5e76\u5c06\u6807\u51c6Base64\u4e2d\u7684\u201c+\u201d\u548c\u201c\/\u201d\u5206\u522b\u6539\u6210\u4e86\u201c*\u201d\u548c\u201c-\u201d\uff0c\u8fd9\u6837\u5c31\u514d\u53bb\u4e86\u5728URL\u7f16\u89e3\u7801\u548c\u6570\u636e\u5e93\u5b58\u50a8\u65f6\u6240\u8981\u4f5c\u7684\u8f6c\u6362\uff0c\u907f\u514d\u4e86\u7f16\u7801\u4fe1\u606f\u957f\u5ea6\u5728\u6b64\u8fc7\u7a0b\u4e2d\u7684\u589e\u52a0\uff0c\u5e76\u7edf\u4e00\u4e86\u6570\u636e\u5e93\u3001\u8868\u5355\u7b49\u5904\u5bf9\u8c61<a href=\"http:\/\/baike.baidu.com\/view\/390932.htm\" target=\"_blank\"><span style=\"color:#136ec2;\">\u6807\u8bc6\u7b26<\/span><\/a>\u7684\u683c\u5f0f\u3002<br \/>\n\u3000\u3000\u53e6\u6709\u4e00\u79cd\u7528\u4e8e<a href=\"http:\/\/baike.baidu.com\/view\/94238.htm\" target=\"_blank\"><span style=\"color:#136ec2;\">\u6b63\u5219\u8868\u8fbe\u5f0f<\/span><\/a>\u7684\u6539\u8fdbBase64\u53d8\u79cd\uff0c\u5b83\u5c06\u201c+\u201d\u548c\u201c\/\u201d\u6539\u6210\u4e86\u201c!... <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/269\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[283],"tags":[90],"class_list":["post-269","post","type-post","status-publish","format-standard","hentry","category-technologys","tag-base64"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=269"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/269\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}