A few more property functinos.

This commit is contained in:
Andrei Zmievski 2006-05-08 21:54:44 +00:00
parent 4cc946a706
commit 002b28e5cc
3 changed files with 91 additions and 4 deletions

View file

@ -69,11 +69,16 @@ PHP_FUNCTION(char_is_valid);
* Other functions * Other functions
*/ */
PHP_FUNCTION(char_to_digit);
PHP_FUNCTION(char_from_digit); PHP_FUNCTION(char_from_digit);
PHP_FUNCTION(char_from_name); PHP_FUNCTION(char_from_name);
PHP_FUNCTION(char_get_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 */ #endif /* PHP_PROPERTY_H */

View 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: * Local variables:
* tab-width: 4 * tab-width: 4

View file

@ -283,9 +283,13 @@ zend_function_entry unicode_functions[] = {
PHP_FE(char_get_type, NULL) PHP_FE(char_get_type, NULL)
PHP_FE(char_is_valid, NULL) PHP_FE(char_is_valid, NULL)
PHP_FE(char_from_digit, NULL) PHP_FE(char_from_digit, NULL)
PHP_FE(char_from_name, NULL) PHP_FE(char_from_name, NULL)
PHP_FE(char_get_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 } { NULL, NULL, NULL }
}; };