|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-02-18 07:54 UTC] mbeiser at w-commerce dot de
Description: ------------ With the PHP Version 5.2.0 there comes a charset-problem concerning the htmlentities-function. While it has worked under PHP4 (setting up the parameters using htaccess), we can't manage to use a htmlentities-function without setting up the charset(UTF-8) with the third parameter. This was tested under Debian Etch13, Ubuntu LTS 8.04 with the PHP Versions 5.2.0 and 5.2.8. Reproduce code: --------------- <?php $text = "Text mit Umlauten: ä ü ö"; echo "htmlentities without exp. charset and htaccess:".htmlentities($text, ENT_COMPAT)."\n"; echo "htmlentities utf-8 :".htmlentities($text, ENT_COMPAT, 'utf-8')."\n"; ?> Expected result: ---------------- htmlentities without exp. charset and htaccess: Text mit Umlauten: ä ü ö htmlentities uf8 : Text mit Umlauten: ä ü ö Actual result: -------------- htmlentities without exp. charset and htaccess: Text mit Umlauten: ä ü ö htmlentities uf8 : Text mit Umlauten: ä ü ö PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 14:00:01 2025 UTC |
Ok, I used the newest version oh php and tested with following script: <? print ini_get('default_charset')."\n"; print ini_get('mbstring.internal_enconding')."\n"; echo "<pre>\n"; $text = "text with umlauts: ? ? ?\n"; echo "t1: ".$text."\n"; echo "htmlentities : ".htmlentities($text)."\n"; echo "htmlentities iso-8859-1: ".htmlentities($text, ENT_COMPAT, 'iso-8859-1')."\n"; echo "htmlentities uf8 : ".htmlentities($text, ENT_COMPAT,'utf-8')."\n"; echo "</pre>\n"; ?> Still got the same Problem. It only works, when I'm defining the third parameter of the htmlentities-signature the charset explicitly. I could reproduce this on several servers.