title: preg_replace error with regex with non-english characters, character is not recognized
body: <p>I am using the following function to remove white-spaces from strings:</p>
  
  <pre><code>$str = preg_replace('/\s+/', '', $str);
  </code></pre>
  
  <p>I am inputting this string of french characters: <code>ù û ü ÿ à â æ ç é è ê ë ï î ô</code> notice each has a space in-between. </p>
  
  <p>The <code>à</code> character isn't recognized; this is how the output looks: <code>ùûüÿ�âæçéèêëïîô</code></p>
  
  <p>Any idea why? I have tried converting the str to UTF-8 before hand as well to no avail.</p>
  
  <hr>
  
  <p>Update: I found the following post (<a href="https://stackoverflow.com/questions/4148216/weird-problem-with-preg-replace-and-chinese-character">Weird problem with preg_replace and chinese character</a>) where adding <code>u</code> to the end of the regex corrects the problem like so:</p>
  
  <pre><code>$str = preg_replace('/\s+/u', '', $str);
  </code></pre>
  
  <p>This seems to fix it, but could someone explain why this is happening along with an official solution explaining what the <code>u</code> is doing in this regex?</p>