It's not an extra character; it's the first byte of a multi-byte Unicode character.
You actually asked the function to do this, by giving it the FILTER_FLAG_ENCODE_LOW | FILTER_FLAG_ENCODE_HIGH
flag expression.
If you don't encode "high" values, the result changes but is still not very useful:
var_dump(trim(filter_var("\nLook ma, there are special characters:\n<>\"'&©", FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW)));
// string(61) " Look ma, there are special characters: "'&┬®"
What to do next really depends on your requirements. I suspect filter_var
is not what you're looking for, if you want to handle Unicode characters too.
If ANSI is enough for you, I found that a quick fix was to change my PHP source file's encoding to ANSI mode (not UTF-8!), fix the now-broken "©" glyph by removing the orphaned "Â", and run the script again:
// string(65) " Look ma, there are special characters: "'&©"
But this is kind of limiting.
Have a read through the following manual pages for more information: