summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2006-05-08 21:54:44 +0000
committerAndrei Zmievski <andrei@php.net>2006-05-08 21:54:44 +0000
commit002b28e5cc105b248351ef0992dbe5c6d9a8a23e (patch)
treee37e59465fa5260c092cd0338a9b46fc4af32837
parent4cc946a7064ead7291bfe8510fb92d7857e61822 (diff)
downloadphp-git-002b28e5cc105b248351ef0992dbe5c6d9a8a23e.tar.gz
A few more property functinos.
-rw-r--r--ext/unicode/php_property.h7
-rw-r--r--ext/unicode/property.c78
-rw-r--r--ext/unicode/unicode.c10
3 files changed, 91 insertions, 4 deletions
diff --git a/ext/unicode/php_property.h b/ext/unicode/php_property.h
index f2b183eb7e..0c20348d44 100644
--- a/ext/unicode/php_property.h
+++ b/ext/unicode/php_property.h
@@ -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 */
diff --git a/ext/unicode/property.c b/ext/unicode/property.c
index ed10bb9350..b139d1ca3b 100644
--- a/ext/unicode/property.c
+++ b/ext/unicode/property.c
@@ -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
diff --git a/ext/unicode/unicode.c b/ext/unicode/unicode.c
index d5c769b97d..8ad62e9038 100644
--- a/ext/unicode/unicode.c
+++ b/ext/unicode/unicode.c
@@ -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 }
};