]> granicus.if.org Git - php/commitdiff
Add a couple more UTF-8 functions.
authorAndrei Zmievski <andrei@php.net>
Mon, 11 Sep 2006 16:32:02 +0000 (16:32 +0000)
committerAndrei Zmievski <andrei@php.net>
Mon, 11 Sep 2006 16:32:02 +0000 (16:32 +0000)
Zend/zend_API.c
Zend/zend_API.h

index 27d0a95645fc2203f7176f42d44c84cf8b4dc5db..4c0576f7b5a5b7a2ddecbd3e450032c9a0efcbdc 100644 (file)
@@ -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)
 {
index 59ee0cc60b970e5df53beaad45339dc5cf9576e8..e76870ed60299c3540b9590d6391b41f6d3c0826 100644 (file)
@@ -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)