问题
I use this regular expression to remove all the punctuation marks from a string input,
$pg_url = preg_replace("/\W+/", " ", $pg_url);
but there are some kind of symbols or special characters I can't remove them, such as
–
when I pass this into my db injection, it will either turns into â
or â€
How can I get rid of these strange stuff?
Thanks.
回答1:
Those characters are encoded in Unicode, specifically UTF-8.
You may want to consider using the iconv family of functions to convert them into some other encoding (e.g. plain ASCII first).
来源:https://stackoverflow.com/questions/4761586/php-regular-expression-to-remove-%c3%a2-or-%c3%a2%e2%82%ac