title: Accents in strings, how to store accented characters in a single char
body: <p>I have to write a small program to remove accents from a string given as input. I also have to create a function that replaces each single character with accent to the corresponding one without accent, and I have a loop that calls the function for each character in my main:</p>
  
  <pre><code>char func (char c)
  {
      string acc = "èé";
      string norm = "ee";
      char ret = c;
  
      for(int i = 0; i &lt; acc.size(); i++)
      {
          if(c == acc[i])
              ret = acc[i];
      }
      return ret;
  }
  </code></pre>
  
  <p>The problem is that if I provide the string "é" as input inside the main, the string is seen as a string of size 2 (see example below), and the function above is called two times instead that once. Moreover the char given as input to the function is not the correct one. I guess I have the same size problem inside my function. Shouldn't this accent be seen as a single character? (I am using UTF-8)</p>
  
  <pre><code>string s = "e";
  cout &lt;&lt; "size:" &lt;&lt; s.size() &lt;&lt; endl;
  s = "è";
  cout &lt;&lt; "size:" &lt;&lt; s.size() &lt;&lt; endl;
  
  OUTPUT
  size:1
  size:2
  </code></pre>
  
  <p>I have solved the problem using the wchar_t ans wstring types, but I need to insert this function in a more complex program and possibly I would like to avoid to change all the code to deal with wstring.</p>
  
  <p>Do I need to change the file encoding? The actual one is:</p>
  
  <pre><code>text/x-c; charset=utf-8
  </code></pre>
  
  <p>Is it possible to write such a function using normal strings and chars?</p>