title: How to uppercase/lowercase UTF-8 characters in C++?
body: <p>Let's imagine I have a UTF-8 encoded <code>std::string</code> containing the following: </p>
  
  <p><code>óó</code></p>
  
  <p>and I'd like to convert it to the following:</p>
  
  <p><code>ÓÓ</code></p>
  
  <p>Ideally I want the uppercase/lowercase approach I'm using to be generic across all of UTF-8. If that's even possible.</p>
  
  <p>The original byte sequence in the string is <code>0xc3b3c3b3</code> (two bytes per character, and two instances of <code>ó</code>) and I'd like the output to be <code>0xc393c393</code> (two instances of <code>Ó</code>). There are <a href="https://stackoverflow.com/questions/17991431/convert-a-unicode-string-in-c-to-upper-case">some examples</a> on StackOverflow but they use wide character strings, and <a href="https://stackoverflow.com/questions/23136837/in-c-when-to-use-wchar-and-when-to-use-char">other answers</a> say you shouldn't be using wide character strings for UTF-8. It also appears that this problem can be very "tricky" in that the output might be dependent upon the user's locale.</p>
  
  <p>I was expecting to just use something like <code>std::toupper()</code>, but the usage is really unclear to me because it seems like I'm not just converting one character at a time but an entire string. Also, this <a href="http://ideone.com/uFKo0B" rel="noreferrer">Ideone example</a> I put together seems to show that <code>toupper()</code> of <code>0xc3b3</code> is just <code>0xc3b3</code>, which is an unexpected result. Calling <code>setlocale</code> to either UTF-8 or ISO8859-1 doesn't appear to change the outcome.</p>
  
  <p>I'd love some guidance if you could shed some light on either what I'm doing wrong or why my question/premise is faulty!</p>