]> granicus.if.org Git - php/commitdiff
A few more property functinos.
authorAndrei Zmievski <andrei@php.net>
Mon, 8 May 2006 21:54:44 +0000 (21:54 +0000)
committerAndrei Zmievski <andrei@php.net>
Mon, 8 May 2006 21:54:44 +0000 (21:54 +0000)
ext/unicode/php_property.h
ext/unicode/property.c
ext/unicode/unicode.c

index f2b183eb7e3b3b83ae9c63d3b989b67952a2f349..0c20348d4485f6370ce419d77881d4a4e0b92b91 100644 (file)
@@ -69,11 +69,16 @@ PHP_FUNCTION(char_is_valid);
  * Other functions
  */
 
-PHP_FUNCTION(char_to_digit);
 PHP_FUNCTION(char_from_digit);
 PHP_FUNCTION(char_from_name);
 PHP_FUNCTION(char_get_name);
 
+PHP_FUNCTION(char_has_binary_property);
+PHP_FUNCTION(char_get_property_value);
+PHP_FUNCTION(char_get_property_value);
+PHP_FUNCTION(char_get_property_min_value);
+PHP_FUNCTION(char_get_property_max_value);
+
 #endif /* PHP_PROPERTY_H */
 
 
index ed10bb9350513de879f90b1a2bd3d6d394a77a78..b139d1ca3bfc3899ef18649721377ddf1a2828a7 100644 (file)
@@ -442,6 +442,84 @@ PHP_FUNCTION(char_get_name)
 
 /* }}} */
 
+/* {{{ Other property functions */
+
+PHP_FUNCTION(char_has_binary_property)
+{
+       UChar           *str = NULL;
+       int              str_len;
+       long             prop;
+       UProperty        uprop; 
+       int                      offset = 0;
+       zend_bool        result = 1;
+       UChar32          ch;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ul", &str, &str_len, &prop) == FAILURE) {
+               return;
+       }
+
+       if (str_len == 0) {
+               RETURN_FALSE;
+       }
+
+       uprop = (UProperty)prop;
+
+       while (offset < str_len && result) {
+               U16_NEXT(str, offset, str_len, ch);
+               result = u_hasBinaryProperty(ch, uprop);
+       }
+
+       RETURN_BOOL(result);
+}
+
+PHP_FUNCTION(char_get_property_value)
+{
+       UChar      *str;
+       int                     str_len;
+       int                     offset = 0;
+       UChar32         ch;
+       long            prop;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ul", &str, &str_len, &prop) == FAILURE) {
+               return;
+       }
+
+       if (str_len == 0) {
+               RETURN_FALSE;
+       }
+
+       U16_NEXT(str, offset, str_len, ch);
+
+       if (prop >= UCHAR_BINARY_START && prop < UCHAR_BINARY_LIMIT) {
+               RETURN_BOOL((zend_bool)u_getIntPropertyValue(ch, (UProperty)prop));
+       } else {
+               RETURN_LONG(u_getIntPropertyValue(ch, (UProperty)prop));
+       }
+}
+
+PHP_FUNCTION(char_get_property_min_value)
+{
+       long prop;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &prop) == FAILURE) {
+               return;
+       }
+       
+       RETURN_LONG(u_getIntPropertyMinValue((UProperty)prop));
+}
+
+PHP_FUNCTION(char_get_property_max_value)
+{
+       long prop;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &prop) == FAILURE) {
+               return;
+       }
+       
+       RETURN_LONG(u_getIntPropertyMaxValue((UProperty)prop));
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4
index d5c769b97db090502e5deeb4925c8eeb99705cf5..8ad62e9038194299c524d98a07dcb52b40962ad0 100644 (file)
@@ -283,9 +283,13 @@ zend_function_entry unicode_functions[] = {
        PHP_FE(char_get_type,                           NULL)
        PHP_FE(char_is_valid,                           NULL)
 
-       PHP_FE(char_from_digit, NULL)
-       PHP_FE(char_from_name, NULL)
-       PHP_FE(char_get_name, NULL)
+       PHP_FE(char_from_digit,                         NULL)
+       PHP_FE(char_from_name,                          NULL)
+       PHP_FE(char_get_name,                           NULL)
+       PHP_FE(char_has_binary_property,        NULL)
+       PHP_FE(char_get_property_value,         NULL)
+       PHP_FE(char_get_property_min_value, NULL)
+       PHP_FE(char_get_property_max_value, NULL)
 
        { NULL, NULL, NULL }
 };