title: Data Conversion in Ruby
body: <p>I am having issue while doing these conversions:</p>
  
  <pre><code>string = "test \\ud83d\\ude01" #into '1f601' and vise versa.
  
  unicode_value = 'U+1F601' #into string '\\ud83d\\ude01'
  </code></pre>
  
  <p>I have tried this method to encode</p>
  
  <pre><code>string.encode('utf-8') #output is "test \\ud83d\\ude01"
  </code></pre>
  
  <p>Also tried this one </p>
  
  <pre><code>string.force_encoding('utf-8')  #output is "test \\ud83d\\ude01"
  </code></pre>
  
  <p>Thanks</p>