From: Andrei Zmievski Date: Mon, 11 Sep 2006 16:32:02 +0000 (+0000) Subject: Add a couple more UTF-8 functions. X-Git-Tag: RELEASE_1_0_0RC1~1702 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21bc25e0250fbdb15060cb5dffe5e789abfe9607;p=php Add a couple more UTF-8 functions. --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 27d0a95645..4c0576f7b5 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1456,6 +1456,7 @@ ZEND_API int add_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL); } + ZEND_API int add_u_assoc_stringl_ex(zval *arg, zend_uchar type, zstr key, uint key_len, char *str, uint length, int duplicate) { zval *tmp; @@ -1466,6 +1467,7 @@ ZEND_API int add_u_assoc_stringl_ex(zval *arg, zend_uchar type, zstr key, uint k return zend_u_symtable_update(Z_ARRVAL_P(arg), type, key, key_len, (void *) &tmp, sizeof(zval *), NULL); } + ZEND_API int add_assoc_unicode_ex(zval *arg, char *key, uint key_len, UChar *str, int duplicate) { zval *tmp; @@ -1528,6 +1530,26 @@ ZEND_API int add_assoc_zstrl_ex(zval *arg, char *key, uint key_len, zend_uchar t return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL); } +ZEND_API int add_assoc_utf8_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate) +{ + zval *tmp; + + MAKE_STD_ZVAL(tmp); + ZVAL_UTF8_STRINGL(tmp, str, length, duplicate); + + return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL); +} + +ZEND_API int add_u_assoc_utf8_stringl_ex(zval *arg, zend_uchar type, zstr key, uint key_len, char *str, uint length, int duplicate) +{ + zval *tmp; + + MAKE_STD_ZVAL(tmp); + ZVAL_UTF8_STRINGL(tmp, str, length, duplicate); + + return zend_u_symtable_update(Z_ARRVAL_P(arg), type, key, key_len, (void *) &tmp, sizeof(zval *), NULL); +} + ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value) { return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &value, sizeof(zval *), NULL); @@ -1641,6 +1663,27 @@ ZEND_API int add_index_zval(zval *arg, ulong index, zval *value) return zend_hash_index_update(Z_ARRVAL_P(arg), index, (void *) &value, sizeof(zval *), NULL); } +ZEND_API int add_index_utf8_string(zval *arg, ulong index, char *str, int duplicate) +{ + zval *tmp; + + MAKE_STD_ZVAL(tmp); + ZVAL_UTF8_STRING(tmp, str, duplicate); + + return zend_hash_index_update(Z_ARRVAL_P(arg), index, (void *) &tmp, sizeof(zval *), NULL); +} + + +ZEND_API int add_index_utf8_stringl(zval *arg, ulong index, char *str, uint length, int duplicate) +{ + zval *tmp; + + MAKE_STD_ZVAL(tmp); + ZVAL_UTF8_STRINGL(tmp, str, length, duplicate); + + return zend_hash_index_update(Z_ARRVAL_P(arg), index, (void *) &tmp, sizeof(zval *), NULL); +} + ZEND_API int add_next_index_long(zval *arg, long n) { diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 59ee0cc60b..e76870ed60 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -405,31 +405,6 @@ ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value); add_assoc_stringl_ex(arg, key, key_len, (char*)(str), length, (flags) & ZSTR_DUPLICATE); \ } -#define add_assoc_utf8_string_ex(arg, key, key_len, str, flags) \ - { \ - UErrorCode status = U_ZERO_ERROR; \ - UChar *u_str; \ - int u_len; \ - int length = strlen(str); \ - zend_string_to_unicode_ex(UG(utf8_conv), &u_str, &u_len, str, length, &status); \ - if ((flags) & ZSTR_AUTOFREE) { \ - efree(str); \ - } \ - add_assoc_unicodel_ex(arg, key, key_len, u_str, u_len, 0); \ - } - -#define add_assoc_utf8_stringl_ex(arg, key, key_len, str, length, flags) \ - { \ - UErrorCode status = U_ZERO_ERROR; \ - UChar *u_str; \ - int u_len; \ - zend_string_to_unicode_ex(UG(utf8_conv), &u_str, &u_len, str, length, &status); \ - if ((flags) & ZSTR_AUTOFREE) { \ - efree(str); \ - } \ - add_assoc_unicodel_ex(arg, key, key_len, u_str, u_len, 0); \ - } - #define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key)+1, __n) #define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key) + 1) #define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key)+1, __b)