1717#include < config.h>
1818#endif
1919
20+ #if __cplusplus >= 201703L
21+ #include < string_view>
22+ #include < unicode/unistr.h>
23+ #endif
24+
25+ extern " C" {
2026#include " php_intl.h"
27+ #include " intl_convert.h"
28+ }
2129#include " collator_class.h"
2230#include " collator_is_numeric.h"
2331#include " collator_convert.h"
24- #include "intl_convert.h"
2532
2633#include < unicode/ustring.h>
2734#include < php.h>
@@ -106,7 +113,7 @@ static void collator_convert_hash_item_from_utf16_to_utf8(
106113/* {{{ collator_convert_hash_from_utf8_to_utf16
107114 * Convert values of the given hash from UTF-8 encoding to UTF-16LE.
108115 */
109- void collator_convert_hash_from_utf8_to_utf16 ( HashTable * hash , UErrorCode * status )
116+ U_CFUNC void collator_convert_hash_from_utf8_to_utf16 ( HashTable* hash, UErrorCode* status )
110117{
111118 zend_ulong hashIndex;
112119 zval *hashData;
@@ -125,7 +132,7 @@ void collator_convert_hash_from_utf8_to_utf16( HashTable* hash, UErrorCode* stat
125132/* {{{ collator_convert_hash_from_utf16_to_utf8
126133 * Convert values of the given hash from UTF-16LE encoding to UTF-8.
127134 */
128- void collator_convert_hash_from_utf16_to_utf8 ( HashTable * hash , UErrorCode * status )
135+ U_CFUNC void collator_convert_hash_from_utf16_to_utf8 ( HashTable* hash, UErrorCode* status )
129136{
130137 zend_ulong hashIndex;
131138 zend_string *hashKey;
@@ -150,7 +157,7 @@ void collator_convert_hash_from_utf16_to_utf8( HashTable* hash, UErrorCode* stat
150157 *
151158 * @return zval* Converted string.
152159 */
153- zval * collator_convert_zstr_utf16_to_utf8 ( zval * utf16_zval , zval * rv )
160+ U_CFUNC zval* collator_convert_zstr_utf16_to_utf8 ( zval* utf16_zval, zval *rv )
154161{
155162 zend_string* u8str;
156163 UErrorCode status = U_ZERO_ERROR;
@@ -168,7 +175,7 @@ zval* collator_convert_zstr_utf16_to_utf8( zval* utf16_zval, zval *rv )
168175}
169176/* }}} */
170177
171- zend_string * collator_convert_zstr_utf8_to_utf16 (zend_string * utf8_str )
178+ U_CFUNC zend_string *collator_convert_zstr_utf8_to_utf16 (zend_string *utf8_str)
172179{
173180 UErrorCode status = U_ZERO_ERROR;
174181
@@ -189,9 +196,9 @@ zend_string *collator_convert_zstr_utf8_to_utf16(zend_string *utf8_str)
189196/* {{{ collator_convert_object_to_string
190197 * Convert object to UTF16-encoded string.
191198 */
192- zval * collator_convert_object_to_string ( zval * obj , zval * rv )
199+ U_CFUNC zval* collator_convert_object_to_string ( zval* obj, zval *rv )
193200{
194- zval * zstr = NULL ;
201+ zval* zstr = nullptr ;
195202 UErrorCode status = U_ZERO_ERROR;
196203
197204 /* Bail out if it's not an object. */
@@ -211,7 +218,7 @@ zval* collator_convert_object_to_string( zval* obj, zval *rv )
211218 }
212219
213220 /* Object wasn't successfully converted => bail out. */
214- if ( zstr == NULL )
221+ if ( zstr == nullptr )
215222 {
216223 COLLATOR_CONVERT_RETURN_FAILED ( obj );
217224 }
@@ -244,7 +251,7 @@ zval* collator_convert_object_to_string( zval* obj, zval *rv )
244251 *
245252 * @return zval* Number. If str is not numeric string return number zero.
246253 */
247- zval * collator_convert_string_to_number ( zval * str , zval * rv )
254+ U_CFUNC zval* collator_convert_string_to_number ( zval* str, zval *rv )
248255{
249256 zval* num = collator_convert_string_to_number_if_possible ( str, rv );
250257 if ( num == str )
@@ -268,7 +275,7 @@ zval* collator_convert_string_to_number( zval* str, zval *rv )
268275 *
269276 * @return zval* Number. If str is not numeric string return number zero.
270277 */
271- zval * collator_convert_string_to_double ( zval * str , zval * rv )
278+ U_CFUNC zval* collator_convert_string_to_double ( zval* str, zval *rv )
272279{
273280 zval* num = collator_convert_string_to_number ( str, rv );
274281 if ( Z_TYPE_P (num) == IS_LONG )
@@ -289,7 +296,7 @@ zval* collator_convert_string_to_double( zval* str, zval *rv )
289296 * @return zval* Number if str is numeric string. Otherwise
290297 * original str param.
291298 */
292- zval * collator_convert_string_to_number_if_possible ( zval * str , zval * rv )
299+ U_CFUNC zval* collator_convert_string_to_number_if_possible ( zval* str, zval *rv )
293300{
294301 uint8_t is_numeric = 0 ;
295302 zend_long lval = 0 ;
@@ -323,7 +330,7 @@ zval* collator_convert_string_to_number_if_possible( zval* str, zval *rv )
323330 *
324331 * @return zend_string* UTF16 string.
325332 */
326- zend_string * collator_zval_to_string (zval * arg )
333+ U_CFUNC zend_string *collator_zval_to_string (zval *arg)
327334{
328335 // TODO: This is extremely weird in that it leaves pre-existing strings alone and does not
329336 // perform a UTF-8 to UTF-16 conversion for them. The assumption is that values that are
@@ -347,9 +354,9 @@ zend_string *collator_zval_to_string(zval *arg)
347354 * @return zval* Normalized copy of arg or unmodified arg
348355 * if normalization is not needed.
349356 */
350- zval * collator_normalize_sort_argument ( zval * arg , zval * rv )
357+ U_CFUNC zval* collator_normalize_sort_argument ( zval* arg, zval *rv )
351358{
352- zval * n_arg = NULL ;
359+ zval* n_arg = nullptr ;
353360
354361 if ( Z_TYPE_P ( arg ) != IS_STRING )
355362 {
0 commit comments