2121#include < string_view>
2222#include < unicode/unistr.h>
2323#endif
24+ #include < unicode/coll.h>
2425
2526#include " php_intl.h"
2627#include " intl_convert.h"
@@ -89,10 +90,10 @@ static int collator_regular_compare_function(zval *result, zval *op1, zval *op2)
8990 {
9091 /* Compare the strings using ICU. */
9192 ZEND_ASSERT (INTL_G (current_collator) != nullptr );
92- ZVAL_LONG (result, ucol_strcoll (
93- INTL_G (current_collator),
93+ UErrorCode status = U_ZERO_ERROR ;
94+ ZVAL_LONG (result, INTL_G (current_collator)-> compare (
9495 INTL_ZSTR_VAL (Z_STR_P (str1_p)), INTL_ZSTR_LEN (Z_STR_P (str1_p)),
95- INTL_ZSTR_VAL (Z_STR_P (str2_p)), INTL_ZSTR_LEN (Z_STR_P (str2_p)) ));
96+ INTL_ZSTR_VAL (Z_STR_P (str2_p)), INTL_ZSTR_LEN (Z_STR_P (str2_p)), status ));
9697 }
9798 else
9899 {
@@ -200,10 +201,10 @@ static int collator_icu_compare_function(zval *result, zval *op1, zval *op2)
200201
201202 /* Compare the strings using ICU. */
202203 ZEND_ASSERT (INTL_G (current_collator) != nullptr );
203- ZVAL_LONG (result, ucol_strcoll (
204- INTL_G (current_collator),
204+ UErrorCode status = U_ZERO_ERROR ;
205+ ZVAL_LONG (result, INTL_G (current_collator)-> compare (
205206 INTL_ZSTR_VAL (str1), INTL_ZSTR_LEN (str1),
206- INTL_ZSTR_VAL (str2), INTL_ZSTR_LEN (str2) ));
207+ INTL_ZSTR_VAL (str2), INTL_ZSTR_LEN (str2), status ));
207208
208209 zend_string_release (str1);
209210 zend_string_release (str2);
@@ -288,7 +289,7 @@ static collator_compare_func_t collator_get_compare_function( const zend_long so
288289/* {{{ Common code shared by collator_sort() and collator_asort() API functions. */
289290static void collator_sort_internal ( int renumber, INTERNAL_FUNCTION_PARAMETERS )
290291{
291- UCollator* saved_collator;
292+ Collator* saved_collator;
292293 intl_error* saved_collator_error;
293294 intl_error sort_error;
294295 collator_compare_func_t saved_compare_func;
@@ -497,7 +498,7 @@ U_CFUNC PHP_FUNCTION( collator_sort_with_sort_keys )
497498 /* Get sort key, reallocating the buffer if needed. */
498499 bufLeft = sortKeyBufSize - sortKeyBufOffset;
499500
500- sortKeyLen = ucol_getSortKey ( co->ucoll ,
501+ sortKeyLen = co->ucoll -> getSortKey (
501502 utf16_buf,
502503 utf16_len,
503504 (uint8_t *)sortKeyBuf + sortKeyBufOffset,
@@ -521,7 +522,7 @@ U_CFUNC PHP_FUNCTION( collator_sort_with_sort_keys )
521522
522523 sortKeyBuf = reinterpret_cast <char *>(erealloc ( sortKeyBuf, sortKeyBufSize ));
523524
524- sortKeyLen = ucol_getSortKey ( co->ucoll , utf16_buf, utf16_len, (uint8_t *)sortKeyBuf + sortKeyBufOffset, bufLeft );
525+ sortKeyLen = co->ucoll -> getSortKey ( utf16_buf, utf16_len, (uint8_t *)sortKeyBuf + sortKeyBufOffset, bufLeft );
525526 }
526527
527528 sortKeyIndxBuf[sortKeyCount].key = (char *)sortKeyBufOffset; /* remember just offset, cause address */
@@ -616,13 +617,13 @@ U_CFUNC PHP_FUNCTION( collator_get_sort_key )
616617
617618 /* ucol_getSortKey is exception in that the key length includes the
618619 * NUL terminator*/
619- key_len = ucol_getSortKey ( co->ucoll , ustr, ustr_len, nullptr , 0 );
620+ key_len = co->ucoll -> getSortKey ( ustr, ustr_len, nullptr , 0 );
620621 if (!key_len) {
621622 efree ( ustr );
622623 RETURN_FALSE ;
623624 }
624625 key_str = zend_string_alloc (key_len, 0 );
625- key_len = ucol_getSortKey ( co->ucoll , ustr, ustr_len, (uint8_t *)ZSTR_VAL (key_str), key_len);
626+ key_len = co->ucoll -> getSortKey ( ustr, ustr_len, (uint8_t *)ZSTR_VAL (key_str), key_len);
626627 efree ( ustr );
627628 if (!key_len) {
628629 zend_string_efree (key_str);
0 commit comments