title: Encoding and decoding in postgresql
body: <p>Let's say we have a string 'a\b'.
  I need to encode it first, save to file, then read it from file and puck back in db.</p>
  
  <p><strong>How to encode and decode text that has escape characters?</strong></p>
  
  <pre><code>select encode(E'a\b'::bytea, 'base64')
  "YQg="
  select decode('YQg=', 'base64')
  "a\010"
  </code></pre>
  
  <p>After decoding I am not getting back string as it was in it's original form.</p>