views:

190

answers:

1

I am just trying to confirm something with htmlspecialchars

I have just converted my database into UTF-8 and I think I finally have it all working, but throughout my code i have used the php htmlspecialchars function

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

Do I need to worry about changing all the entries to :

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

The PHP documention suggests I don't need to, but I wanted to check with you lot first!

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

Thanks in advance!

+2  A: 

All characters "handled" by htmlspecialchars() are in the 7-bit/US ascii range. And those are identical (and unmistakable) in the mentioned encodings. So yes, it will do no harm if you don't change the encoding parameter. But I'd encourage you to do so anyway.

VolkerK