title: How to convert hex to ASCII while preserving non-printable characters
body: <p>I've been experiencing some weird issues today while debugging, and I've managed to trace this to something I overlooked at first.</p>
  <p>Take a look at the outputs of these two commands:</p>
  <pre><code>root@test:~# printf '%X' 10 | xxd -r -p | xxd -p
  root@test:~# printf '%X' 43 | xxd -r -p | xxd -p
  2b
  root@test:~#
  </code></pre>
  <p>The first xxd command converts hex to ASCII. The second converts ASCII back to hex. (43 decimal = 2b hex).</p>
  <p>Unfortunately, it seems that converting hex to ASCII does <strong>not</strong> preserve non-printable characters. For example, the raw hex &quot;A&quot; (10 decimal = A hex), somehow gets eaten up by <code>xxd -r -p</code>. Thus, when I perform the inverse operation, I get an empty result.</p>
  <p>What I am trying to do is feed some data into minimodem. I need to generate Call Waiting Caller ID (FSK), effectively via bit banging. My bash script has the right bits, but if I do a hexdump, the non-printable characters are missing. Unfortunately, it seem that minimodem only accepts ASCII characters, and I need to feed it raw hex, but it seems that gets eaten up in the conversion. Is it possible to preserve these characters somehow? I don't see it as any option, so wondering if there's a better way.</p>