]> granicus.if.org Git - php/commitdiff
Some more property functions.
authorAndrei Zmievski <andrei@php.net>
Wed, 3 May 2006 22:03:10 +0000 (22:03 +0000)
committerAndrei Zmievski <andrei@php.net>
Wed, 3 May 2006 22:03:10 +0000 (22:03 +0000)
# I am pondering a different prefix..

ext/unicode/php_property.h
ext/unicode/property.c
ext/unicode/unicode.c

index 3c3de57cdf922c7de2d4d682580c890c5abc7dbd..6136db095b871575a8aee61a9d238b31f97e2af0 100644 (file)
@@ -53,6 +53,17 @@ PHP_FUNCTION(unicode_is_u_alphabetic);
 PHP_FUNCTION(unicode_is_u_uppercase);
 PHP_FUNCTION(unicode_is_u_lowercase);
 
+/*
+ * Single character property functions.
+ */
+
+PHP_FUNCTION(unicode_get_numeric_value);
+PHP_FUNCTION(unicode_get_combining_class);
+PHP_FUNCTION(unicode_get_digit_value);
+PHP_FUNCTION(unicode_get_mirror);
+PHP_FUNCTION(unicode_get_direction);
+PHP_FUNCTION(unicode_get_char_type);
+PHP_FUNCTION(unicode_is_char_valid);
 
 #endif /* PHP_PROPERTY_H */
 
index 8daecd8cd4a470226969ac2f56db136483cff5ae..fde55223dc52169d86d2d0a1a9b1e3b82b058745 100644 (file)
@@ -109,9 +109,7 @@ PHP_FUNCTION(unicode_is_print)
 
 /* }}} */
 
-/*
- * Additional binary property functions
- */
+/* {{{ Additional binary property functions */
 
 PHP_FUNCTION(unicode_is_title)
 {
@@ -178,6 +176,146 @@ PHP_FUNCTION(unicode_is_u_lowercase)
        check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isULowercase);
 }
 
+/* }}} */
+
+/* {{{ Single character properties */
+
+PHP_FUNCTION(unicode_get_numeric_value)
+{
+       UChar      *str;
+       int                     str_len;
+       int                     offset = 0;
+       UChar32         ch;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "u", &str, &str_len) == FAILURE) {
+               return;
+       }
+
+       if (str_len == 0) {
+               RETURN_FALSE;
+       }
+       U16_NEXT(str, offset, str_len, ch);
+
+       RETURN_DOUBLE(u_getNumericValue(ch));
+}
+
+PHP_FUNCTION(unicode_get_combining_class)
+{
+       UChar      *str;
+       int                     str_len;
+       int                     offset = 0;
+       UChar32         ch;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "u", &str, &str_len) == FAILURE) {
+               return;
+       }
+
+       if (str_len == 0) {
+               RETURN_FALSE;
+       }
+       U16_NEXT(str, offset, str_len, ch);
+
+       RETURN_LONG((long)u_getCombiningClass(ch));
+}
+
+PHP_FUNCTION(unicode_get_digit_value)
+{
+       UChar      *str;
+       int                     str_len;
+       int                     offset = 0;
+       UChar32         ch;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "u", &str, &str_len) == FAILURE) {
+               return;
+       }
+
+       if (str_len == 0) {
+               RETURN_FALSE;
+       }
+       U16_NEXT(str, offset, str_len, ch);
+
+       RETURN_LONG(u_charDigitValue(ch));
+}
+
+PHP_FUNCTION(unicode_get_mirror)
+{
+       UChar      *str;
+       int                     str_len;
+       int                     offset = 0, buf_len;
+       UChar32         ch;
+       UChar       buf[3];
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "u", &str, &str_len) == FAILURE) {
+               return;
+       }
+
+       if (str_len == 0) {
+               RETURN_FALSE;
+       }
+       U16_NEXT(str, offset, str_len, ch);
+       buf_len = zend_codepoint_to_uchar(u_charMirror(ch), buf);
+
+       RETURN_UNICODEL(buf, buf_len, 1);
+}
+
+PHP_FUNCTION(unicode_get_direction)
+{
+       UChar      *str;
+       int                     str_len;
+       int                     offset = 0;
+       UChar32         ch;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "u", &str, &str_len) == FAILURE) {
+               return;
+       }
+
+       if (str_len == 0) {
+               RETURN_FALSE;
+       }
+       U16_NEXT(str, offset, str_len, ch);
+
+       RETURN_LONG((long)u_charDirection(ch));
+}
+
+PHP_FUNCTION(unicode_get_char_type)
+{
+       UChar      *str;
+       int                     str_len;
+       int                     offset = 0;
+       UChar32         ch;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "u", &str, &str_len) == FAILURE) {
+               return;
+       }
+
+       if (str_len == 0) {
+               RETURN_FALSE;
+       }
+       U16_NEXT(str, offset, str_len, ch);
+
+       RETURN_LONG(u_charType(ch));
+}
+
+PHP_FUNCTION(unicode_is_char_valid)
+{
+       UChar      *str;
+       int                     str_len;
+       int                     offset = 0;
+       UChar32         ch;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "u", &str, &str_len) == FAILURE) {
+               return;
+       }
+
+       if (str_len == 0) {
+               RETURN_FALSE;
+       }
+       U16_NEXT(str, offset, str_len, ch);
+
+       RETURN_BOOL(U_IS_UNICODE_CHAR(ch));
+}
+
+/* }}} */
 
 /*
  * Local variables:
index dde3ef54af3073cadfde466d37b5528a5d1b5a5c..f603aef415427eb8e684f1398e95efb681cb4028 100644 (file)
@@ -276,6 +276,14 @@ zend_function_entry unicode_functions[] = {
        PHP_FE(unicode_is_u_uppercase,  NULL)
        PHP_FE(unicode_is_u_lowercase,  NULL)
 
+       PHP_FE(unicode_get_numeric_value,       NULL)
+       PHP_FE(unicode_get_combining_class, NULL)
+       PHP_FE(unicode_get_digit_value,         NULL)
+       PHP_FE(unicode_get_mirror,                      NULL)
+       PHP_FE(unicode_get_direction,           NULL)
+       PHP_FE(unicode_get_char_type,           NULL)
+       PHP_FE(unicode_is_char_valid,           NULL)
+
        { NULL, NULL, NULL }
 };
 /* }}} */