note 41152 deleted from function.htmlentities by cmb
| From: | cmb@php.net | Date: | Sun, 01 Dec 2019 08:32:01 +0000 |
| Subject: | note 41152 deleted from function.htmlentities by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213299@lists.php.net to get a copy of this message | ||
Note Submitter: wwb at 3dwargamer dot net
----
htmlentites is a very handy function, but it fails to fix one thing which I deal with alot: word
'smart' quotes and emdashes.
The below function replaces the funky double quotes with ", funky single quotes with
standard single quotes and fixes emdashes.
<?php
function CleanupSmartQuotes($text)
{
$badwordchars=array(
chr(145),
chr(146),
chr(147),
chr(148),
chr(151)
);
$fixedwordchars=array(
"'",
"'",
'"',
'"',
'—'
);
return str_replace($badwordchars,$fixedwordchars,$text);
}
?>