I have the same problem. This is because of UTF8.
à is 0xc3a0 in UTF8. In PHP, you can write like this: "\xc3\xa0" .
Using PCRE /s corresponds to 0xa0 , as it was ASCII "Non-breaking space".
You can use u flag to solve the problem.
$html = preg_replace("/\s/u", "", $html);
source share