htmlspecialchars()
only converts &, “, ‘, < and >. To also convert (encode, really) accented characters, you need to use htmlentities()
, and depending on the rest of your setup you may also have to specify which encoding to use. So:
$content = htmlspecialchars( $text, ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8' );
(Substitute 'ISO-8859-1'
for 'UTF-8'
if necessary, though it probably won’t be.)