title: Why does UTF8 seam to switch from 8 to a padded 64 bit when storing in memory?
body: <p>Apologies for the nubeness of the question but I've been chasing my tail for days.</p>
  
  <p>I need to create a function that can verify whether the encoding of a buffer being received is actually UTF8 and then do a basic regex to exclude unwanted control chars.</p>
  
  <p>I started by recursively dumping:</p>
  
  <pre><code>     0x62     
       0xCDBC     
       0xE0AC89     
       0xF09F8489   
  </code></pre>
  
  <p>Into a test file.</p>
  
  <p>It worked fine, copied the file and text editors from windows, Linux &amp; mac can read it (and display the correct char's)</p>
  
  <p>But when I try to read it back into my test function it dies, added a     </p>
  
  <pre><code>char c = fs-&gt;get();    
  while(fs-&gt;good())
  {     
       int len = sizeof(c);     
       printf("0x%X        ---    %i\n",c,len);     
       c = fs-&gt;get();     
  }  
  </code></pre>
  
  <p>Yes I know the code sucks..</p>
  
  <p>but what I don't understand is why I'm getting this on the output.</p>
  
  <pre><code>Hex                    sizeof()
  0x26              ---    1     
  0xFFFFFFCD        ---    1     
  0xFFFFFFBC        ---    1    
  0xFFFFFFE0        ---    1     
  0xFFFFFFAC        ---    1     
  0xFFFFFF89        ---    1     
  0xFFFFFFF0        ---    1     
  0xFFFFFF9F        ---    1     
  0xFFFFFF84        ---    1     
  0xFFFFFFB9        ---    1     
  </code></pre>
  
  <p>The 0x62 becomes a 0x26 whilst all the other numbers are correct but padded into a 64 bit pattern...?</p>
  
  <p>locale is EN_en.utf8</p>
  
  <p>I'm lost, any ideas out there?</p>
  
  <p>Thanks in advance
  Bob.</p>