Re: Re: can i rely on ctype?

From: Date: Mon, 16 Jul 2007 10:51:42 +0000
Subject: Re: Re: can i rely on ctype?
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-30967@lists.php.net to get a copy of this message
Hi, Lukas Kahwe Smith wrote:
can you gives us a clarification on the question on if ctype will infact be deprecated in PHP6?
ctype is not UTF-16 aware and therefore won't work with PHP 6 unicode strings. Instead of ctype there are functions offered by ICU which will be available for PHP 6. So even if it ould be shipped with PHP 6 it, most likely, won't be useful. And I doubt it makes sense to use ctype functions wrapping ICU, but this might be done using PEAR's PHP_Compat or something.
Just for completness, Stephan Walk offered the following explanation on the pear mailinglist: A pretty major change that makes perfect sense. When PHP6 is there, there are char_is_*-functions using ICU (the unicode library). Those functions do everything that ctype does in a more coherent way, example: swalk@itchy:~/programming/php/php6> ./php-unicode -r 'var_dump(ctype_digit(123));' bool(false) swalk@itchy:~/programming/php/php6> ./php-unicode -r 'var_dump(char_is_digit(123));' bool(true) So you don't have to explicitely cast to string anymore when you want to check that a value you got is either an integer or a string containing only an integer, which is more like string/int juggling works in the rest of php ... to summarize, you have new functions offering the same functionality and more, and have a cleaner API ... so the rational thing to do is deprecate the old functionality. It won't be gone, but folks should be made aware that better things are available.
OK, so if I understand correctly, then ctype should be used in PHP5 since better functions are not yet available. But as soon as PHP6 is out and apps are changed for it ctype functions should be replaced by new Unicode-aware functions?

« previous php.internals (#30967) next »