title: Trimming UTF8 buffer
body: <p>I have a buffer with UTF8 data. I need to remove the leading and trailing spaces. 
  Here is the C code which does it (in place) for ASCII buffer:
  <code></p>
  
  <pre>
  char *trim(char *s)
  {
    while( isspace(*s) )
      memmove( s, s+1, strlen(s) );
    while( *s && isspace(s[strlen(s)-1]) )
      s[strlen(s)-1] = 0;
    return s;
  }
  </pre>
  
  <p></code></p>
  
  <p>How to do the same for UTF8 buffer in C/C++?
  <br>P.S.
  Thanks for perfomance tip regarding strlen(). Back to UTF8 specific: what if I need to remove all spaces all together, not only at beginning and at the tail? Also I may need to remove all characters with ASCII code &lt;32. Is any specific here  for UTF8 case, like using mbstowcs()? </p>