title: How to decode an URI with UTF-8 characters in C++
body: <p>I need to decode an URI in C++. I found several questions about it, but they all fail to deal with UTF-8 encoding and accents (I'm interested in accurately dealing with ASCII characters).</p>
  
  <p>Then, I went with a broadly used library like libcurl... but it also failed to address the UTF-8 encoding. Here's what I'm doing</p>
  
  <pre><code>string UriHelper::Decode(const string &amp;encoded)
  {
      CURL *curl = curl_easy_init();
      int outlength;
      char *cres = curl_easy_unescape(curl, encoded.c_str(), encoded.length(), &amp;outlength);
      string res(cres, cres + outlength);
      curl_free(cres);
      curl_easy_cleanup(curl);
      return res;
  }
  </code></pre>
  
  <p>The problem is that <code>a%C3%A1e%C3%A9i%C3%ADo%C3%B3u%C3%BA</code> gets decoded as <code>aÃ¡eÃ©iÃ­oÃ³uÃº</code> when it should be <code>aáeéiíoóuú</code>. If I use <code>a%E1e%E9i%EDo%F3u%FA</code> it works just fine.</p>
  
  <p>Is there any library out there that can take care of differently encoded URIs and deal with them?</p>
  
  <p>Thanks!</p>