Define default encoding for htmlentities ()

I was wondering if there is a way to determine the default encoding for htmlentities(). I have a large project that uses calls htmlentitieseverywhere, and wondered if there was an easy way to set it from ISO-8859-1 to UTF-8 as the default encoding using something simple, for example init_set. Or perhaps with a separate namespace declaration .

Otherwise, I will not mind renaming and overriding the function htmlentitiesto always use Unicode, but I do not want to install anything as fancy (to me) as the PECL apd .

+5
source share
2 answers

Since the manual page does not say anything about changing the default encoding, I don’t think there is a way to do this; and I don’t remember ever seeing anything about it.

I would not use anything similar to apd - instead, I would assume:

  • create my own function that calls htmlentities with the correct parameters
  • and replace each htmlentities call with a call to my new function (this can probably be done automatically using a few lines of scripts)
+8
source
Decision

@Pascal MARTIN is definitely correct, you can also use utf8-encodeto convert ISO-8859-1 to UTF-8.

And utf8_decodeto convert UTF-8 to ISO-8859-1.

0

All Articles