|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-10-17 18:18 UTC] tularis@php.net
[2008-10-17 19:22 UTC] rrichards@php.net
[2008-10-20 12:47 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 01:00:01 2025 UTC |
Description: ------------ Using the DOMText function splitText() on a text node containing multibyte characters results in the node being split at the wrong position. Reproduce code: --------------- $text = 'This is an ?example? of using DOM splitText'; $start = 30; $length = 3; $dom = new DOMDocument('1.0', 'UTF-8'); $node = $dom->createTextNode($text); $dom->appendChild($node); print "Text: $node->textContent\n"; print 'Expected (mb_substr): ' . mb_substr($text, $start, $length, 'UTF-8') . "\n"; $matched = $node->splitText($start); $matched->splitText($length); print "Actual (splitText): $matched->textContent\n"; Expected result: ---------------- Text: This is an ?example? of using DOM splitText Expected (mb_substr): DOM Actual (splitText): DOM Actual result: -------------- Text: This is an ?example? of using DOM splitText Expected (mb_substr): DOM Actual (splitText): ing