Lets assume the following string is entered into a form and submitted to a PHP script.
“€ should encode as €”
I would like to know how to actually get € to encode as € htmlentities() doesn’t do it, what voodoo is needed in order to get that to encode properly (and others like it)?
It works with
htmlentities. But you need to make sure to use the proper character set ashtmlentities’ default character set ISO 8859-1 does not contain that character; but ISO 8859-15 for example does:Here the
"\xA4"will result in the byte 0xA4 that is the code of€in ISO 8859-15.So just make sure to use a character set that contains that character.