title: Elixir: String Force encode UTF-8
body: <p>I have a gem in ruby that does translations using google API and I am "translating" it to Elixir.</p>
  
  <p>For example, I get from API some like this:
  <a href="https://translate.google.com/translate_a/single?client=p&amp;sl=en&amp;tl=pt-CN&amp;ie=UTF-8&amp;oe=UTF-8&amp;dt=t&amp;dt=rm&amp;q=Hello," rel="nofollow">api-data</a></p>
  
  <p>And in Ruby today I do this:</p>
  
  <pre><code>  encoded = rawdata.force_encoding("UTF-8")
  </code></pre>
  
  <p>I would like to know if there is a way to "force_encode" (like Ruby does) but with Elixir?</p>
  
  <p><strong>UPDATE SOLUTION</strong></p>
  
  <p>I reached a solution based in your answers guys thanks a lot!</p>
  
  <p>As Elixir handle it as binaries then that is the trick: I get the response body: <code>body |&gt; IO.iodata_to_binary ...</code></p>
  
  <pre><code>defmodule Request do
    alias Extract
    use HTTPotion.Base
  
    def process_url(url) do
      "https://translate.google.com/translate_a/" &lt;&gt; url
    end
  
    def process_response_body(body) do
      body |&gt; IO.iodata_to_binary |&gt; Extract.extract
    end
  end
  </code></pre>
  
  <p><a href="https://github.com/CristianOliveiraDaRosa/elixfregle" rel="nofollow">Here is entire code</a></p>