xref: /PHP-8.2/ext/dom/tests/bug46335.phpt (revision bd9f4fa6)
1--TEST--
2Bug #46335 (DOMText::splitText doesn't handle multibyte characters).
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7$textascii = 'This is an "example" of using DOM splitText';
8$text = 'This is an ‘example’ of using DOM splitText';
9$start = 30;
10$length = 3;
11
12$dom = new DOMDocument('1.0', 'UTF-8');
13$node = $dom->createTextNode($textascii);
14$dom->appendChild($node);
15
16print "Text: $node->textContent\n";
17
18$matched = $node->splitText($start);
19$matched->splitText($length);
20print "splitText (ASCII): $matched->textContent\n";
21
22$node = $dom->createTextNode($text);
23$dom->appendChild($node);
24
25print "Text: $node->textContent\n";
26
27$matched = $node->splitText($start);
28$matched->splitText($length);
29print "splitText (UTF-8): $matched->textContent\n";
30?>
31--EXPECT--
32Text: This is an "example" of using DOM splitText
33splitText (ASCII): DOM
34Text: This is an ‘example’ of using DOM splitText
35splitText (UTF-8): DOM
36