{"id":2672,"date":"2017-09-01T00:01:06","date_gmt":"2017-09-01T07:01:06","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=2672"},"modified":"2017-09-08T07:52:35","modified_gmt":"2017-09-08T14:52:35","slug":"the-url-decoding-filter","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=2672","title":{"rendered":"The URL Decoding Filter"},"content":{"rendered":"<p><a href=\"http:\/\/c-for-dummies.com\/blog\/?p=2626\">Last month&#8217;s Exercise<\/a> was to write a filter that converts ASCII text into a percent-encoded format. This month, you&#8217;re task is to reverse the process: White a filter that converts a percent-encoded string back into the original ASCII.<br \/>\n<!--more--><br \/>\nAs a review, the first filter takes a string such as <code>http:\/\/c-for-dummies.com\/blog\/?p=2672<\/code> and generates this output:<\/p>\n<p><code>http%3A%2F%2Fc-for-dummies.com%2Fblog%2F%3Fp%3D2672<\/code><\/p>\n<p>This filter, following the HTML5 guidelines, retains alphanumeric text, as well as the characters <code>- . _<\/code> and <code>*<\/code>. Spaces are converted to the <code>+<\/code> character. Everything else is translated into a three-character string: a percent sign followed by a two-digit hexadecimal value representing the original character&#8217;s ASCII code.<\/p>\n<p>To reverse the process, you must retain those characters not converted and convert back spaces and any percent-encoded characters. The real issue is how to take a string such as <code>%3A<\/code> and change it back to a <code>:<\/code> (colon). As a hint, such code has already been presented elsewhere in this blog.<\/p>\n<p>Please try this Exercise on your own before you check out <a href=\"http:\/\/c-for-dummies.com\/blog\/?p=2681\">my solution<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Take a string of percent-encoded text and revert it back to the original ASCII. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=2672\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-2672","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2672"}],"version-history":[{"count":4,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2672\/revisions"}],"predecessor-version":[{"id":2704,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2672\/revisions\/2704"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}