{"id":5117,"date":"2022-01-01T00:01:26","date_gmt":"2022-01-01T08:01:26","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=5117"},"modified":"2022-01-08T08:22:39","modified_gmt":"2022-01-08T16:22:39","slug":"decoding-a-string","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=5117","title":{"rendered":"Decoding a String"},"content":{"rendered":"<h2>Difficulty: Medium<\/h2>\n<p>The task for <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=5074\">last month&#8217;s Exercise<\/a> was to encode a string. As you may have feared, the task for this month&#8217;s Exercise is to decode that string. Let me review:<br \/>\n<!--more--><br \/>\nThe method for string encoding presented last month works like this:<\/p>\n<ol>\n<li>Translate a character (or byte) into its two-digit hexadecimal value.<\/li>\n<li>Translate the next character into a two-digit hex value minus the first character\u2019s value.<\/li>\n<li>Repeat Step 2 until all the data is processed.<\/li>\n<\/ol>\n<p>To obtain the original string, you must work backwards: The first character&#8217;s ASCII code value is represented as a two-digit hex value. The next character is the difference between the first and second characters, again represented as a two-digit hex value. Each subsequent character is the same: the difference between the current character and the previous one. But this math isn&#8217;t the most difficult part of the puzzle.<\/p>\n<p>No, another perhaps unforeseen problem is ensure that you properly interpret the two-digit hex values.<\/p>\n<p>As with last month&#8217;s Exercise, for this month&#8217;s Exercise you must create a filter. The filter reads standard input and converts the hex digits into characters. You can test your solution on the string presented at the start of last month&#8217;s Exercise:<\/p>\n<p><code>48190F0009A72827FDFDFBFD18FAAD460CFDFEB323EA192903BB1731F800FCFC0E97<\/code><\/p>\n<p>When I run this string through my solution, I see this output:<\/p>\n<p><code>Happy Holidays from C-For-Dummies<\/code><\/p>\n<p>Aw. &#129392;<\/p>\n<p><a href=\"https:\/\/c-for-dummies.com\/blog\/?p=5132\">Click here<\/a> to view my solution, though please try this Exercise on your own rather than see what I did first.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>48190F0009A72E1712A9390CFC11AFE9 <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=5117\">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-5117","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\/5117","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=5117"}],"version-history":[{"count":6,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5117\/revisions"}],"predecessor-version":[{"id":5157,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5117\/revisions\/5157"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}