I want only uncoded characters to be converted to html objects without affecting entities that are already present. I have a string that previously encoded objects, for example:
gaIUSHIUGhj>‐ hjb×jkn.jhuh>hh> …
When I use htmlentities() , & at the beginning of entities is encrypted again. This means ‐ and other objects have & encoded to & :
×
I tried to decode the complete string, and then coded it again, but it does not work properly. This is the code I tried:
header('Content-Type: text/html; charset=iso-8859-1'); ... $b = 'gaIUSHIUGhj>‐ hjb×jkn.jhuh>hh> …'; $b = html_entity_decode($b, ENT_QUOTES, 'UTF-8'); $b = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $b); $b = htmlentities($b, ENT_QUOTES, 'UTF-8');
But it does not seem to work correctly. Is there a way to prevent or stop this?
source share