ID: 36596 Updated by: [EMAIL PROTECTED] Reported By: preben at infofab dot no -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Linux FC4 PHP Version: Irrelevant New Comment:
This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. "This function returns byte index according to UTF-8 encoded text disregarding if input is in another encoding." Previous Comments: ------------------------------------------------------------------------ [2006-03-03 12:37:34] preben at infofab dot no Sorry, an error in statement - correct version $ch = substr($data, $byte, 7); The "bug" still stands though... ------------------------------------------------------------------------ [2006-03-03 12:37:32] preben at infofab dot no Sorry, an error in statement - correct version $ch = substr($data, $byte, 7); The "bug" still stands though... ------------------------------------------------------------------------ [2006-03-03 00:12:33] preben at infofab dot no Description: ------------ The function xml_get_current_byte_index() returns byte index according to utf8 encoded text - disregarding if input is in ISO-8859-1. If you would like to cach a chunk of data from a xml file you would need to convert input to utf8 to get the correct calculations. Reproduce code: --------------- $data = "<?xml version='1.0' encoding='iso8859-1'?>\n<data>\n<dummy>øææø</dummy>\n<row>ÆØÅdata</row>\n</data>\n"; function startElement($parser, $name, $attrs) { global $data; if($name != "ROW") return; $byte = xml_get_current_byte_index($parser) + 41; $ch = substr($data, $byte + 41, 7); # The following calculates correct # $ch = utf8_decode(substr(utf8_encode($data), $byte, 7)); echo "$name ($byte): $ch\n"; exit(); } function endElement($parser, $name) { } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_parse($xml_parser, $data, 1); Expected result: ---------------- ROW (79): ÆØÅd Actual result: -------------- ROW (79): ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36596&edit=1