title: std::hex and std::setw not working with some characters
body: <p>What I'm trying to do is converting a string's bytes into hexadecimal format.<br>
  Based on <a href="https://stackoverflow.com/a/3382894/878711">this answer</a> (and many others consistent) I've tried the code:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;sstream&gt;
  #include &lt;iomanip&gt;
  #include &lt;iostream&gt;
  
  int main ()
  {
     std::string inputText = u8"A7°";
  
     std::stringstream ss;
     // print every char of the string as hex on 2 values
     for (unsigned int i = 0; i &lt; inputText.size (); ++i)
     {
        ss &lt;&lt; std::hex &lt;&lt; std::setfill ('0') &lt;&lt; std::setw (2) &lt;&lt; (int) inputText[i];
     }
  
     std::cout &lt;&lt; ss.str() &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>but with some characters coded in UTF 8 it does't work.<br>
  For Instance, in strings containing the degrees symbol ( &deg; ) coded in UTF8, the result is: <code>ffffffc2ffffffb0</code> instead of <code>c2b0</code>.<br>
  Now I would expect the algorithm to work on individual bytes regardless of their contents and furthermore the result seems to ignore the <code>setw(2)</code> parameter.<br>
  Why does I get such a result?</p>
  
  <p>(run test program <a href="https://onlinegdb.com/BkNu5ipYS" rel="nofollow noreferrer">here</a>)</p>