htmlentities() and default_charset

From: Date: Sat, 08 Nov 2008 23:54:32 +0000
Subject: htmlentities() and default_charset
Groups: php.general 
Request: Send a blank email to php-general+get-283100@lists.php.net to get a copy of this message
Folks, Why should htmlentities() use the default_charset for $charset with this example, taken from ext/standard/tests/strings/htmlentities10.phpt? <?php ini_set('mbstring.internal_encoding','pass'); ini_set('default_charset','cp1252'); var_dump(htmlentities("\x82\x86\x99\x9f", ENT_QUOTES, '')); ?> The test script expects the output to be: string(28) "&sbquo;&dagger;&trade;&Yuml;" According to the PHP Manual, the htmlentities() syntax is: string htmlentities ( string $string [, int $quote_style [, string $charset [, bool $double_encode ]]] ) For the parameter charset: "Like htmlspecialchars(), it takes an optional third argument charset which defines character set used in conversion. Presently, the ISO-8859-1 character set is used as the default." It goes on to list the supported values for charset and states: "Note: Any other character sets are not recognized and ISO-8859-1 will be used instead." Therefore, when $charset = '' I would expect that htmlentities("\x82\x86\x99\x9f", ENT_QUOTES, '') would use ISO-8859-1 since the null string is not listed as a supported value. Also, it does not mention the use of default_charset. Furthermore, when default_charset = '', PHP states that ISO-8859-1 will be used as the default. Since the $charset is optional, I would expect htmlentities("\x82\x86\x99\x9f", ENT_QUOTES) would use the default_charset, but not htmlentities("\x82\x86\x99\x9f", ENT_QUOTES, ''). However, test scripts ext/standard/tests/strings/htmlentities10.phpt, htmlentities11.phpt, and htmlentities13.phpt all expect the default_charset to be used when charset=''. Thanks. Jim ----- Jim Hermann <hostmaster@UUism.net> UUism Networks <http://www.UUism.net> Ministering to the Needs of Online UUs Web Hosting, Email Services, Mailing Lists -----

« previous php.general (#283100) next »