xref: /PHP-7.2/ext/dom/tests/bug46335.phpt (revision 17ccbeec)
1--TEST--
2Bug #46335 (DOMText::splitText doesn't handle multibyte characters).
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
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