From: Andrei Zmievski Date: Mon, 14 Aug 2006 22:00:46 +0000 (+0000) Subject: Unicode support for strcoll(). X-Git-Tag: RELEASE_1_0_0RC1~1953 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd927905eeb087345a024bcd54edbb424dff0227;p=php Unicode support for strcoll(). --- diff --git a/ext/standard/string.c b/ext/standard/string.c index e2e045e26e..850be0e9dd 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -494,24 +494,32 @@ PHP_FUNCTION(nl_langinfo) #endif /* }}} */ -#ifdef HAVE_STRCOLL -/* {{{ proto int strcoll(string str1, string str2) +/* {{{ proto int strcoll(string str1, string str2) U Compares two strings using the current locale */ PHP_FUNCTION(strcoll) { - zval **s1, **s2; + zstr s1, s2; + int s1_len, s2_len; + zend_uchar str_type; - if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &s1, &s2) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "TT", &s1, &s1_len, + &str_type, &s2, &s2_len, &str_type) == FAILURE) { + return; + } + + if (str_type == IS_UNICODE) { + RETURN_LONG(ZEND_COLL_RESULT(ucol_strcoll(UG(default_collator)->coll, s1.u, s1_len, s2.u, s2_len))); + } else { +#ifdef HAVE_STRCOLL + RETURN_LONG(strcoll((const char *) s1.s, + (const char *) s2.s)); +#else + RETURN_FALSE; +#endif } - convert_to_string_ex(s1); - convert_to_string_ex(s2); - RETURN_LONG(strcoll((const char *) Z_STRVAL_PP(s1), - (const char *) Z_STRVAL_PP(s2))); } /* }}} */ -#endif /* {{{ php_charmask * Fills a 256-byte bytemask with input. You can specify a range like 'a..z', diff --git a/unicode-progress.txt b/unicode-progress.txt index 7196354252..8fc9c72ff0 100644 --- a/unicode-progress.txt +++ b/unicode-progress.txt @@ -43,8 +43,6 @@ ext/standard Params API. Rest - no idea yet. str_replace() - Params API, IS_UNICODE upgrade - stri_replace() Params API, IS_UNICODE upgrade. Case-folding should be handled similar to stristr(). @@ -52,9 +50,6 @@ ext/standard str_word_count() Params API, IS_UNICODE support, using u_isalpha(), etc. - strcoll() - Params API, upgrade to use Collator if TT == IS_UNICODE, test - stristr() This is the problematic one. There are a few approaches: @@ -188,6 +183,7 @@ ext/standard str_rot13() str_shuffle() str_split() + strcoll() strcspn() strip_tags() stripcslashes()