title: Decode hexadecimal string in Ruby
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/862140/hex-to-binary-in-ruby">Hex to binary in ruby</a>  </p>
  </blockquote>
  
  
  
  <p>In Python, I can do the following:</p>
  
  <pre><code>&gt;&gt;&gt; str = '000E0000000000'
  &gt;&gt;&gt; str.decode('hex')
  '\x00\x0e\x00\x00\x00\x00\x00'
  </code></pre>
  
  <p>If I have to achieve the same output in ruby which call could I make? I tried <code>to_s(16)</code>, which doesn't seem to work. I need the output to be in that specific format, so I expect to get the following:</p>
  
  <pre><code>"\\x00\\x0e\\x00\\x00\\x00\\x00\\x00"
  </code></pre>