note 105687 added to function.ctype-alnum

From: Date: Wed, 07 Sep 2011 15:26:52 +0000
Subject: note 105687 added to function.ctype-alnum
Groups: php.notes 
Request: Send a blank email to php-notes+get-183005@lists.php.net to get a copy of this message
I'm using PHP 5.3.5 and, for me at least, there seems to be an important caveat with this function. The current system locale *is* being honoured, but Unicode (or at least UTF-8) is not giving the expected results. Thus: <?php //note script file itself its UTF-8 $utf8_string = 'jérômecaractèresdelachaîne'; $iso_string = iconv('UTF-8', 'ISO-8859-1', $utf8_string); //or: //$iso_string = mb_convert_encoding($utf8_string, 'ISO-8859-1', 'UTF-8'); setlocale(LC_ALL, 'fr_FR.utf8'); var_dump(nl_langinfo(CODESET)); //gives UTF-8 var_dump(ctype_alnum($utf8_string)); //gives FALSE setlocale(LC_ALL, 'fr_FR'); var_dump(nl_langinfo(CODESET)); //gives ISO-8859-1 var_dump(ctype_alnum($iso_string)); //gives TRUE ?> ---- Server IP: 92.48.74.199 Probable Submitter: 86.148.73.218 ---- Manual Page -- http://www.php.net/manual/en/function.ctype-alnum.php Edit -- https://master.php.net/note/edit/105687 Del: integrated -- https://master.php.net/note/delete/105687/integrated Del: useless -- https://master.php.net/note/delete/105687/useless Del: bad code -- https://master.php.net/note/delete/105687/bad+code Del: spam -- https://master.php.net/note/delete/105687/spam Del: non-english -- https://master.php.net/note/delete/105687/non-english Del: in docs -- https://master.php.net/note/delete/105687/in+docs Del: other reasons-- https://master.php.net/note/delete/105687 Reject -- https://master.php.net/note/reject/105687 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183005) next »