PHP - htmlspecialchars and UTF-8

I'm just trying to confirm something htmlspecialchars . I just converted my database to UTF-8 and I think that finally it all works, but in all my code I used PHP htmlspecialchars :

 htmlspecialchars($val, ENT_QUOTES,'ISO-8859-1',false); 

I need to worry about changing all entries:

 htmlspecialchars($val, ENT_QUOTES,'UTF-8',false); 

The PHP documentation assumes I don't need this, but is that true?

For the purpose of this function, the encodings ISO-8859-1, ISO-8859-15, UTF-8, cp866, cp1251, cp1252 and KOI8-R are practically equivalent, since the characters affected by htmlspecialchars () occupy the same positions in all of these encodings.

+2
source share
1 answer

All characters processed by htmlspecialchars () are in the 7-bit / US ASCII range. And those are identical (and unmistakably) in the mentioned encodings. So yes, it will not hurt if you do not change the encoding parameter. But I urge you to do it anyway.

+4
source

All Articles