title: How to remove repeating white-space characters from UTF8 string in PHP properly with regex?
body: <p>I'm trying to remove repeating white-space characters from UTF8 string in PHP using regex.
  This regex</p>
  
  <pre><code>    $txt = preg_replace( '/\s+/i' , ' ', $txt );
  </code></pre>
  
  <p>usually works fine, but some of the strings have Cyrillic letter "Р", which is screwed after the replacement.
  After small research I realized that the letter is encoded as  \x{D0A0}, and since \xA0 is non-breaking white space in ASCII the regex replaces it with \x20 and the character is no longer valid.</p>
  
  <p>Any ideas how to do this properly in PHP with regex?</p>