andrei Mon May 8 22:23:58 2006 UTC Modified files: /php-src/ext/unicode php_property.h property.c unicode.c Log: And going, and going... http://cvs.php.net/viewcvs.cgi/php-src/ext/unicode/php_property.h?r1=1.5&r2=1.6&diff_format=u Index: php-src/ext/unicode/php_property.h diff -u php-src/ext/unicode/php_property.h:1.5 php-src/ext/unicode/php_property.h:1.6 --- php-src/ext/unicode/php_property.h:1.5 Mon May 8 21:54:44 2006 +++ php-src/ext/unicode/php_property.h Mon May 8 22:23:57 2006 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_property.h,v 1.5 2006/05/08 21:54:44 andrei Exp $ */ +/* $Id: php_property.h,v 1.6 2006/05/08 22:23:57 andrei Exp $ */ #ifndef PHP_PROPERTY_H #define PHP_PROPERTY_H @@ -78,6 +78,8 @@ PHP_FUNCTION(char_get_property_value); PHP_FUNCTION(char_get_property_min_value); PHP_FUNCTION(char_get_property_max_value); +PHP_FUNCTION(char_get_property_name); +PHP_FUNCTION(char_get_property_from_name); #endif /* PHP_PROPERTY_H */ http://cvs.php.net/viewcvs.cgi/php-src/ext/unicode/property.c?r1=1.9&r2=1.10&diff_format=u Index: php-src/ext/unicode/property.c diff -u php-src/ext/unicode/property.c:1.9 php-src/ext/unicode/property.c:1.10 --- php-src/ext/unicode/property.c:1.9 Mon May 8 21:54:44 2006 +++ php-src/ext/unicode/property.c Mon May 8 22:23:57 2006 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: property.c,v 1.9 2006/05/08 21:54:44 andrei Exp $ */ +/* $Id: property.c,v 1.10 2006/05/08 22:23:57 andrei Exp $ */ #include "php_unicode.h" @@ -369,15 +369,16 @@ PHP_FUNCTION(char_from_name) { - UChar *name; + void *name; int name_len; + zend_uchar name_type; UChar32 ch; UCharNameChoice choice = U_UNICODE_CHAR_NAME; zend_bool extended = FALSE; char *buf; UErrorCode status = U_ZERO_ERROR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "u|b", &name, &name_len, &extended) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|b", &name, &name_len, &name_type, &extended) == FAILURE) { return; } @@ -385,19 +386,27 @@ choice = U_EXTENDED_CHAR_NAME; } - buf = zend_unicode_to_ascii(name, name_len TSRMLS_CC); - if (buf) { - ch = u_charFromName(choice, buf, &status); - if (U_SUCCESS(status)) { - RETVAL_UCHAR32(ch); - } else { - RETVAL_FALSE; + if (name_type == IS_UNICODE) { + buf = zend_unicode_to_ascii(name, name_len TSRMLS_CC); + if (buf == NULL) { + php_error(E_WARNING, "Character name has to consist only of ASCII characters"); + RETURN_FALSE; } } else { - php_error(E_WARNING, "Character name has to consist only of ASCII characters"); + buf = (char *) name; + } + + ch = u_charFromName(choice, buf, &status); + + if (name_type == IS_UNICODE) { + efree(buf); + } + + if (U_SUCCESS(status)) { + RETURN_UCHAR32(ch); + } else { RETURN_FALSE; } - efree(buf); } PHP_FUNCTION(char_get_name) @@ -518,6 +527,60 @@ RETURN_LONG(u_getIntPropertyMaxValue((UProperty)prop)); } + +PHP_FUNCTION(char_get_property_name) +{ + long prop; + long name_choice = U_LONG_PROPERTY_NAME; + const char *name; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &prop, &name_choice) == FAILURE) { + return; + } + + if (name_choice < 0) { + name_choice = U_LONG_PROPERTY_NAME; + } + + name = u_getPropertyName((UProperty) prop, (UPropertyNameChoice) name_choice); + if (name) { + RETURN_ASCII_STRING((char *)name, ZSTR_DUPLICATE); + } else { + RETURN_FALSE; + } + +} + +PHP_FUNCTION(char_get_property_from_name) +{ + void *name; + int name_len; + zend_uchar name_type; + char *buf; + UProperty prop; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &name, &name_len, &name_type) == FAILURE) { + return; + } + + if (name_type == IS_UNICODE) { + buf = zend_unicode_to_ascii(name, name_len TSRMLS_CC); + if (buf == NULL) { + php_error(E_WARNING, "Property name has to consist only of ASCII characters"); + RETURN_FALSE; + } + } else { + buf = (char *) name; + } + + prop = u_getPropertyEnum(buf); + if (name_type == IS_UNICODE) { + efree(buf); + } + + RETURN_LONG(prop); +} + /* }}} */ /* http://cvs.php.net/viewcvs.cgi/php-src/ext/unicode/unicode.c?r1=1.30&r2=1.31&diff_format=u Index: php-src/ext/unicode/unicode.c diff -u php-src/ext/unicode/unicode.c:1.30 php-src/ext/unicode/unicode.c:1.31 --- php-src/ext/unicode/unicode.c:1.30 Mon May 8 21:54:44 2006 +++ php-src/ext/unicode/unicode.c Mon May 8 22:23:57 2006 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: unicode.c,v 1.30 2006/05/08 21:54:44 andrei Exp $ */ +/* $Id: unicode.c,v 1.31 2006/05/08 22:23:57 andrei Exp $ */ #include "php_unicode.h" #include "zend_unicode.h" @@ -290,6 +290,8 @@ PHP_FE(char_get_property_value, NULL) PHP_FE(char_get_property_min_value, NULL) PHP_FE(char_get_property_max_value, NULL) + PHP_FE(char_get_property_name, NULL) + PHP_FE(char_get_property_from_name, NULL) { NULL, NULL, NULL } };
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php