diff options
author | Sean Bright <elixer@php.net> | 2001-01-17 01:10:50 +0000 |
---|---|---|
committer | Sean Bright <elixer@php.net> | 2001-01-17 01:10:50 +0000 |
commit | a588d655910367aeee48e4301a9db9faad9e5f90 (patch) | |
tree | 8a39db7d46bc0542d2362ce6515181f57af339fa /ext/standard | |
parent | b8b40f697eb9b58deca4d1f3e6074443d3671dd8 (diff) | |
download | php-git-a588d655910367aeee48e4301a9db9faad9e5f90.tar.gz |
Added string comparison function strcoll(). It uses the current locale to
do the comparisons.
@- Added localeconv() and strcoll() functions for localization. (Sean)
Diffstat (limited to 'ext/standard')
-rw-r--r-- | ext/standard/basic_functions.c | 5 | ||||
-rw-r--r-- | ext/standard/php_string.h | 5 | ||||
-rw-r--r-- | ext/standard/string.c | 18 |
3 files changed, 27 insertions, 1 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 4c71abf18e..4293d78730 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -162,6 +162,11 @@ function_entry basic_functions[] = { PHP_FE(strstr, NULL) PHP_FE(stristr, NULL) PHP_FE(strrchr, NULL) +#ifdef HAVE_STRCOLL + PHP_FE(strcoll, NULL) +#else + PHP_FALIAS(strcoll, warn_not_available, NULL) +#endif PHP_FE(substr, NULL) PHP_FE(substr_replace, NULL) PHP_FE(quotemeta, NULL) diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h index 7a2c5ecfb0..c59f716e57 100644 --- a/ext/standard/php_string.h +++ b/ext/standard/php_string.h @@ -79,9 +79,12 @@ PHP_FUNCTION(strnatcasecmp); PHP_FUNCTION(substr_count); PHP_FUNCTION(str_pad); PHP_FUNCTION(sscanf); +#ifdef HAVE_STRCOLL +PHP_FUNCTION(strcoll); +#endif -#if defined(HAVE_LOCALECONV) && defined(ZTS) +#ifdef ZTS PHP_MINIT_FUNCTION(localeconv); PHP_MSHUTDOWN_FUNCTION(localeconv); #endif diff --git a/ext/standard/string.c b/ext/standard/string.c index 98e0c3a73b..15311417c5 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -210,6 +210,24 @@ PHP_FUNCTION(strcspn) } /* }}} */ +#ifdef HAVE_STRCOLL +/* {{{ proto int strcoll(string str1, string str2) + Compare two strings using the current locale */ +PHP_FUNCTION(strcoll) +{ + zval **s1, **s2; + + if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &s1, &s2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_string_ex(s1); + convert_to_string_ex(s2); + + RETURN_LONG(strcoll((const char *)(*s1)->value.str.val, (const char *)(*s2)->value.str.val)); +} +#endif + PHPAPI void php_trim(zval *str, zval * return_value, int mode) /* mode 1 : trim left mode 2 : trim right |