note 105688 added to function.ctype-alpha
| From: | daniel dot rhodes at warpasylum dot co dot uk | Date: | Wed, 07 Sep 2011 15:34:32 +0000 |
| Subject: | note 105688 added to function.ctype-alpha | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183006@lists.php.net to get a copy of this message | ||
I'm not having the success that Tyrunur is having with UTF-8. For me, on PHP 5.3.5, it only
seems to work when both the locale and the string are ISO-8859-1. Thus:
<?php
//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_alpha($utf8_string)); //gives FALSE
setlocale(LC_ALL, 'fr_FR');
var_dump(nl_langinfo(CODESET)); //gives ISO-8859-1
var_dump(ctype_alpha($iso_string)); //gives TRUE
?>
My ctype_alnum() also seems to dislike UTF-8...
----
Server IP: 92.48.74.199
Probable Submitter: 86.148.73.218
----
Manual Page -- http://www.php.net/manual/en/function.ctype-alpha.php
Edit -- https://master.php.net/note/edit/105688
Del: integrated -- https://master.php.net/note/delete/105688/integrated
Del: useless -- https://master.php.net/note/delete/105688/useless
Del: bad code -- https://master.php.net/note/delete/105688/bad+code
Del: spam -- https://master.php.net/note/delete/105688/spam
Del: non-english -- https://master.php.net/note/delete/105688/non-english
Del: in docs -- https://master.php.net/note/delete/105688/in+docs
Del: other reasons-- https://master.php.net/note/delete/105688
Reject -- https://master.php.net/note/reject/105688
Search -- https://master.php.net/manage/user-notes.php