Unicode support

This commit is contained in:
Dmitry Stogov 2007-07-11 16:47:30 +00:00
parent bf16e86999
commit d3a6deb076
2 changed files with 14 additions and 4 deletions

View File

@ -1094,16 +1094,22 @@ PHP_METHOD(xmlreader, XML)
int source_len = 0, encoding_len = 0;
long options = 0;
xmlreader_object *intern = NULL;
char *source, *uri = NULL, *encoding = NULL;
zstr source;
char *uri = NULL, *encoding = NULL;
int resolved_path_len;
char *directory=NULL, resolved_path[MAXPATHLEN];
xmlParserInputBufferPtr inputbfr;
xmlTextReaderPtr reader = NULL;
zend_uchar source_type;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|s!l", &source, &source_len, &encoding, &encoding_len, &options) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|s!l", &source, &source_len, &source_type, &encoding, &encoding_len, &options) == FAILURE) {
return;
}
if (source_type == IS_UNICODE) {
source.s = php_libxml_unicode_to_string(source.u, source_len, &source_len TSRMLS_CC);
}
id = getThis();
if (id != NULL && ! instanceof_function(Z_OBJCE_P(id), xmlreader_class_entry TSRMLS_CC)) {
id = NULL;
@ -1118,7 +1124,11 @@ PHP_METHOD(xmlreader, XML)
RETURN_FALSE;
}
inputbfr = xmlParserInputBufferCreateMem(source, source_len, XML_CHAR_ENCODING_NONE);
inputbfr = xmlParserInputBufferCreateMem(source.s, source_len, XML_CHAR_ENCODING_NONE);
if (source_type == IS_UNICODE) {
efree(source.s);
}
if (inputbfr != NULL) {
/* Get the URI of the current script so that we can set the base directory in libxml */

View File

@ -22,7 +22,7 @@ $xmlstring = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
</MOVIE>
</LIST>';
$dtdfile = rawurlencode(dirname(__FILE__)) . b'/dtdexample.dtd';
$dtdfile = rawurlencode((binary)dirname(__FILE__)) . b'/dtdexample.dtd';
$file = dirname(__FILE__) . '/__008.xml';
file_put_contents($file, $xmlstring);