Another PHP UTF-8 problem: htmlentities, htmlspecialchars and html_entity_decode

htmlentities, htmlspecialchars and html_entity_decode have 3 parameters:

  1. string to be converted
  2. quote_style
  3. charset

but charset default is ISO-8859-1 and there’s no way to change that default, what happens if you’re porting 1,000,000 lines of code from ISO-8859-1 to UTF-8? you’ve to wrap those functions or patch every call passing all the 3 params. All these 2 solutions are bad solutions.

PHP should implement a customizable default, maybe also reading mbstring.internal_encoding if available.

Leave a Reply

Your email address will not be published. Required fields are marked *