]> granicus.if.org Git - php/commitdiff
Unicode support
authorDmitry Stogov <dmitry@php.net>
Wed, 7 Dec 2005 16:52:13 +0000 (16:52 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 7 Dec 2005 16:52:13 +0000 (16:52 +0000)
12 files changed:
ext/simplexml/simplexml.c
ext/simplexml/tests/000.phpt
ext/simplexml/tests/001.phpt
ext/simplexml/tests/002.phpt
ext/simplexml/tests/003.phpt
ext/simplexml/tests/004.phpt
ext/simplexml/tests/007.phpt
ext/simplexml/tests/010.phpt
ext/simplexml/tests/022.phpt
ext/simplexml/tests/023.phpt
ext/simplexml/tests/024.phpt
ext/spl/tests/sxe_001.phpt

index 6d2b2b2efe148e3d6cd1743b947895ca79333961..f4e97e6016de7d94dc5b2415a766cd5265e1e96d 100644 (file)
@@ -746,16 +746,6 @@ static void sxe_dimension_delete(zval *object, zval *offset TSRMLS_DC)
 }
 /* }}} */
 
-static inline char * sxe_xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine)
-{
-       xmlChar *tmp = xmlNodeListGetString(doc, list, inLine);
-       char    *res = estrdup((char*)tmp);
-
-       xmlFree(tmp);
-       
-       return res;
-}
-
 /* {{{ _get_base_node_value()
  */
 static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value, char *prefix TSRMLS_DC)
@@ -768,7 +758,7 @@ static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval
        if (node->children && node->children->type == XML_TEXT_NODE && !xmlIsBlankNode(node->children)) {
                contents = xmlNodeListGetString(node->doc, node->children, 1);
                if (contents) {
-                       ZVAL_STRING(*value, contents, 1);
+                       ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), *value, contents, 1);
                        xmlFree(contents);
                }
        } else {
@@ -846,8 +836,11 @@ static HashTable * sxe_properties_get(zval *object TSRMLS_DC)
                test = sxe->iter.name && sxe->iter.type == SXE_ITER_ATTRLIST;
                while (attr) {
                        if ((!test || !xmlStrcmp(attr->name, sxe->iter.name)) && match_ns(sxe, (xmlNodePtr)attr, sxe->iter.nsprefix)) {
+                               xmlChar *tmp;
+
                                MAKE_STD_ZVAL(value);
-                               ZVAL_STRING(value, sxe_xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1), 0);
+                               ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, tmp = xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1), 1);
+                               xmlFree(tmp);
                                namelen = xmlStrlen(attr->name) + 1;
                                if (!zattr) {
                                        MAKE_STD_ZVAL(zattr);
@@ -864,8 +857,11 @@ static HashTable * sxe_properties_get(zval *object TSRMLS_DC)
        node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
        if (node && sxe->iter.type != SXE_ITER_ATTRLIST) {
                if (node->type == XML_ATTRIBUTE_NODE) {
+                       xmlChar *tmp;
+
                        MAKE_STD_ZVAL(value);
-                       ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, sxe_xmlNodeListGetString(node->doc, node->children, 1), 0);
+                       ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, tmp = xmlNodeListGetString(node->doc, node->children, 1), 1);
+                       xmlFree(tmp);
                        zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL);
                        node = NULL;
                } else {
@@ -877,8 +873,11 @@ static HashTable * sxe_properties_get(zval *object TSRMLS_DC)
                                SKIP_TEXT(node);
                        } else {
                                if (node->type == XML_TEXT_NODE) {
+                                       xmlChar *tmp;
+
                                        MAKE_STD_ZVAL(value);
-                                       ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, sxe_xmlNodeListGetString(node->doc, node, 1), 0);
+                                       ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, tmp = xmlNodeListGetString(node->doc, node, 1), 1);
+                                       xmlFree(tmp);
                                        zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL);
                                        goto next_iter;
                                }
index 4af67010b361bf5199ce72356c5898ddf4212987..d11c271dac93bb51a6586f2e076b6c36161a1807 100755 (executable)
@@ -261,20 +261,20 @@ object(SimpleXMLElement)#%d (3) {
   [u"@attributes"]=>
   array(1) {
     [u"id"]=>
-    string(3) "123"
+    unicode(3) "123"
   }
   [u"elem1"]=>
   array(2) {
     [0]=>
-    string(36) "There is some text.Here is some more"
+    unicode(36) "There is some text.Here is some more"
     [1]=>
     object(SimpleXMLElement)#%d (1) {
       [u"@attributes"]=>
       array(2) {
         [u"attr1"]=>
-        string(2) "11"
+        unicode(2) "11"
         [u"attr2"]=>
-        string(2) "12"
+        unicode(2) "12"
       }
     }
   }
@@ -296,9 +296,9 @@ object(SimpleXMLElement)#%d (3) {
   [u"@attributes"]=>
   array(2) {
     [u"attr1"]=>
-    string(5) "first"
+    unicode(5) "first"
     [u"attr2"]=>
-    string(6) "second"
+    unicode(6) "second"
   }
   [u"comment"]=>
   object(SimpleXMLElement)#%d (0) {
@@ -308,9 +308,9 @@ object(SimpleXMLElement)#%d (3) {
     [u"@attributes"]=>
     array(2) {
       [u"att25"]=>
-      string(2) "25"
+      unicode(2) "25"
       [u"att42"]=>
-      string(2) "42"
+      unicode(2) "42"
     }
     [u"elem3"]=>
     object(SimpleXMLElement)#%d (1) {
@@ -331,9 +331,9 @@ object(SimpleXMLElement)#%d (3) {
   [u"@attributes"]=>
   array(2) {
     [u"attr1"]=>
-    string(5) "first"
+    unicode(5) "first"
     [u"attr2"]=>
-    string(6) "second"
+    unicode(6) "second"
   }
   [u"comment"]=>
   object(SimpleXMLElement)#%d (0) {
@@ -343,9 +343,9 @@ object(SimpleXMLElement)#%d (3) {
     [u"@attributes"]=>
     array(2) {
       [u"att25"]=>
-      string(2) "25"
+      unicode(2) "25"
       [u"att42"]=>
-      string(2) "42"
+      unicode(2) "42"
     }
     [u"elem3"]=>
     object(SimpleXMLElement)#%d (1) {
@@ -366,9 +366,9 @@ object(SimpleXMLElement)#%d (2) {
   [u"@attributes"]=>
   array(2) {
     [u"att25"]=>
-    string(2) "25"
+    unicode(2) "25"
     [u"att42"]=>
-    string(2) "42"
+    unicode(2) "42"
   }
   [u"elem3"]=>
   object(SimpleXMLElement)#%d (1) {
@@ -400,9 +400,9 @@ object(SimpleXMLElement)#%d (1) {
   [u"@attributes"]=>
   array(2) {
     [u"attr1"]=>
-    string(2) "11"
+    unicode(2) "11"
     [u"attr2"]=>
-    string(2) "12"
+    unicode(2) "12"
   }
 }
 ===sxe->elem1[2]
index 5dc9abfd6fd177fb71fa35d355918d41ec2d25a3..b5c51ff96079ca4854c36f32c61ed0c0f80dcd9b 100644 (file)
@@ -46,14 +46,14 @@ object(SimpleXMLElement)#%d (2) {
   [u"@attributes"]=>
   array(1) {
     [u"id"]=>
-    string(5) "elem1"
+    unicode(5) "elem1"
   }
   [u"elem1"]=>
   object(SimpleXMLElement)#%d (3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr1"]=>
-      string(5) "first"
+      unicode(5) "first"
     }
     [u"comment"]=>
     object(SimpleXMLElement)#%d (0) {
index 8632207d245061bf5171efc66c0ff5190ab19863..6d1679faa49d35de4ff77658982e9c7ed4eff1b0 100644 (file)
@@ -67,14 +67,14 @@ object(SimpleXMLElement)#%d (2) {
   [u"@attributes"]=>
   array(1) {
     [u"id"]=>
-    string(5) "elem1"
+    unicode(5) "elem1"
   }
   [u"elem1"]=>
   object(SimpleXMLElement)#%d (3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr1"]=>
-      string(5) "first"
+      unicode(5) "first"
     }
     [u"comment"]=>
     object(SimpleXMLElement)#%d (0) {
index 978768a366544e6b46fd35a9a1510df0eb4be028..9cb5c0e5dcf4b2684abb61ef4efe228649df19df 100755 (executable)
@@ -72,14 +72,14 @@ object(SimpleXMLElement)#%d (2) {
   [u"@attributes"]=>
   array(1) {
     [u"id"]=>
-    string(5) "elem1"
+    unicode(5) "elem1"
   }
   [u"elem1"]=>
   object(SimpleXMLElement)#%d (3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr1"]=>
-      string(5) "first"
+      unicode(5) "first"
     }
     [u"comment"]=>
     object(SimpleXMLElement)#%d (0) {
@@ -91,7 +91,7 @@ object(SimpleXMLElement)#%d (2) {
         [u"included-entity"]=>
         object(SimpleXMLElement)#%d (1) {
           [u"included-entity"]=>
-          string(36) "This is text included from an entity"
+          unicode(36) "This is text included from an entity"
         }
         [u"elem4"]=>
         object(SimpleXMLElement)#%d (1) {
index c2f462be6bff17c3549d51737c8c3c9cf945da91..bb5916440beaeebc286a6c43477b567f332b0959 100755 (executable)
@@ -71,14 +71,14 @@ object(SimpleXMLElement)#%d (2) {
   [u"@attributes"]=>
   array(1) {
     [u"id"]=>
-    string(5) "elem1"
+    unicode(5) "elem1"
   }
   [u"elem1"]=>
   object(SimpleXMLElement)#%d (3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr1"]=>
-      string(5) "first"
+      unicode(5) "first"
     }
     [u"comment"]=>
     object(SimpleXMLElement)#%d (0) {
index 5a7ba29deb25237b5c6577942d7aa2004428e9fd..5a2cf6f9c0566b0b9585f73c54e3fb6c3366a5f1 100755 (executable)
@@ -101,7 +101,7 @@ object(SimpleXMLElement)#%d (3) {
   [u"@attributes"]=>
   array(1) {
     [u"attr1"]=>
-    string(5) "first"
+    unicode(5) "first"
   }
   [u"comment"]=>
   object(SimpleXMLElement)#%d (0) {
index a71618ba0162dd4a03bfe395b71d00c94e5108ed..5318a525a37ef21c445dcb0e99fc2c2b19ebbcf5 100644 (file)
@@ -67,14 +67,14 @@ object(simplexml_inherited)#%d (2) {
   [u"@attributes"]=>
   array(1) {
     [u"id"]=>
-    string(5) "elem1"
+    unicode(5) "elem1"
   }
   [u"elem1"]=>
   object(simplexml_inherited)#%d (3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr1"]=>
-      string(5) "first"
+      unicode(5) "first"
     }
     [u"comment"]=>
     object(simplexml_inherited)#%d (0) {
index 36cc0145b35874627e8896922367db5020beb46d..5374bbaa2d5775a1196ff6ddc3a39b1fc487ff68 100755 (executable)
@@ -68,7 +68,7 @@ object(SimpleXMLElement)#%d (1) {
     [u"@attributes"]=>
     array(1) {
       [u"glob"]=>
-      string(11) "slide_*.xml"
+      unicode(11) "slide_*.xml"
     }
   }
 }
@@ -77,7 +77,7 @@ object(SimpleXMLElement)#%d (1) {
   [u"@attributes"]=>
   array(1) {
     [u"glob"]=>
-    string(11) "slide_*.xml"
+    unicode(11) "slide_*.xml"
   }
 }
 ===FOREACH===
@@ -85,7 +85,7 @@ object(SimpleXMLElement)#%d (1) {
   [u"@attributes"]=>
   array(1) {
     [u"glob"]=>
-    string(11) "slide_*.xml"
+    unicode(11) "slide_*.xml"
   }
 }
 object(SimpleXMLElement)#%d (1) {
index 449daf47b7b5007c3843990353512f16ccd31708..be82b78f3829c47e7727ea55f629240509b71961 100755 (executable)
@@ -39,7 +39,7 @@ object(SimpleXMLElement)#%d (1) {
   [u"@attributes"]=>
   array(1) {
     [u"attr"]=>
-    string(%d) "foo%sbar%sbaz"
+    unicode(%d) "foo%sbar%sbaz"
   }
 }
 object(SimpleXMLElement)#%d (1) {
index a136cfb9cca21374b32d60dc1f2d6fe97788bb4d..018d7e50b6c2ca76caaf94dbec012671a56f004e 100755 (executable)
@@ -181,7 +181,7 @@ array(3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr2"]=>
-      string(2) "12"
+      unicode(2) "12"
     }
   }
   [1]=>
@@ -189,7 +189,7 @@ array(3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr2"]=>
-      string(2) "22"
+      unicode(2) "22"
     }
   }
   [2]=>
@@ -197,7 +197,7 @@ array(3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr2"]=>
-      string(2) "32"
+      unicode(2) "32"
     }
   }
 }
@@ -208,7 +208,7 @@ array(3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr2"]=>
-      string(2) "12"
+      unicode(2) "12"
     }
   }
   [1]=>
@@ -216,7 +216,7 @@ array(3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr2"]=>
-      string(2) "22"
+      unicode(2) "22"
     }
   }
   [2]=>
@@ -224,7 +224,7 @@ array(3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr2"]=>
-      string(2) "32"
+      unicode(2) "32"
     }
   }
 }
@@ -235,7 +235,7 @@ array(9) {
     [u"@attributes"]=>
     array(1) {
       [u"attr1"]=>
-      string(2) "11"
+      unicode(2) "11"
     }
   }
   [1]=>
@@ -243,7 +243,7 @@ array(9) {
     [u"@attributes"]=>
     array(1) {
       [u"attr2"]=>
-      string(2) "12"
+      unicode(2) "12"
     }
   }
   [2]=>
@@ -251,7 +251,7 @@ array(9) {
     [u"@attributes"]=>
     array(1) {
       [u"attr3"]=>
-      string(2) "13"
+      unicode(2) "13"
     }
   }
   [3]=>
@@ -259,7 +259,7 @@ array(9) {
     [u"@attributes"]=>
     array(1) {
       [u"attr1"]=>
-      string(2) "21"
+      unicode(2) "21"
     }
   }
   [4]=>
@@ -267,7 +267,7 @@ array(9) {
     [u"@attributes"]=>
     array(1) {
       [u"attr2"]=>
-      string(2) "22"
+      unicode(2) "22"
     }
   }
   [5]=>
@@ -275,7 +275,7 @@ array(9) {
     [u"@attributes"]=>
     array(1) {
       [u"attr3"]=>
-      string(2) "23"
+      unicode(2) "23"
     }
   }
   [6]=>
@@ -283,7 +283,7 @@ array(9) {
     [u"@attributes"]=>
     array(1) {
       [u"attr1"]=>
-      string(2) "31"
+      unicode(2) "31"
     }
   }
   [7]=>
@@ -291,7 +291,7 @@ array(9) {
     [u"@attributes"]=>
     array(1) {
       [u"attr2"]=>
-      string(2) "32"
+      unicode(2) "32"
     }
   }
   [8]=>
@@ -299,7 +299,7 @@ array(9) {
     [u"@attributes"]=>
     array(1) {
       [u"attr3"]=>
-      string(2) "33"
+      unicode(2) "33"
     }
   }
 }
@@ -310,7 +310,7 @@ array(1) {
     [u"@attributes"]=>
     array(1) {
       [u"attr2"]=>
-      string(2) "22"
+      unicode(2) "22"
     }
   }
 }
index 11d8eeee23970a88fe7151aad65f2c23a543d37b..0f5530249e6a5075c87677b613f604da17276c14 100755 (executable)
@@ -67,14 +67,14 @@ object(SimpleXMLIterator)#%d (2) {
   [u"@attributes"]=>
   array(1) {
     [u"id"]=>
-    string(5) "elem1"
+    unicode(5) "elem1"
   }
   [u"elem1"]=>
   object(SimpleXMLIterator)#%d (3) {
     [u"@attributes"]=>
     array(1) {
       [u"attr1"]=>
-      string(5) "first"
+      unicode(5) "first"
     }
     [u"comment"]=>
     object(SimpleXMLIterator)#%d (0) {