title: How to UTF-8 encode a character/string
body: <p>I am using a Twitter API library to post a status to Twitter. Twitter requires that the post be UTF-8 encoded. The library contains a function that URL encodes a standard string, which works perfectly for all special characters such as !@#$%^&amp;*() but is the incorrect encoding for accented characters (and other UTF-8).</p>
  
  <p>For example, 'é' gets converted to '%E9' rather than '%C3%A9' (it pretty much only converts to a hexadecimal value). Is there a built-in function that could input something like 'é' and return something like '%C9%A9"?</p>
  
  <p>edit: I am fairly new to UTF-8 in case what I am requesting makes no sense.</p>
  
  <p>edit: if I have a </p>
  
  <pre><code>string foo = "bar é";
  </code></pre>
  
  <p>I would like to convert it to</p>
  
  <pre><code>"bar %C3%A9"
  </code></pre>
  
  <p>Thanks</p>