File: cpbi_getLastCodePoint_basic.phpt

package info (click to toggle)
php5 5.6.33%2Bdfsg-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 157,872 kB
  • sloc: ansic: 756,065; php: 22,030; sh: 12,311; cpp: 8,771; xml: 6,179; yacc: 1,564; exp: 1,514; makefile: 1,467; pascal: 1,147; awk: 538; perl: 315; sql: 22
file content (82 lines) | stat: -rw-r--r-- 1,968 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--TEST--
IntlCodepointBreakIterator::getLastCodePoint(): basic test
--SKIPIF--
<?php
if (!extension_loaded('intl'))
	die('skip intl extension not enabled');
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");

$text = 'ตัวอย่างข้อความ';

$codepoint_it = IntlBreakIterator::createCodePointInstance();
$codepoint_it->setText($text);

var_dump($codepoint_it->getLastCodePoint());
//first() and last() don't read codepoint and set the last code point var to -1
//The pointer is after the last read codepoint if moving forward and
//before the last read codepoint is moving backwards
$p = $codepoint_it->first();
while ($p != IntlBreakIterator::DONE) {
	$c = $codepoint_it->getLastCodePoint();
	if ($c > 0)
		var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint()));
	else
		var_dump($c);
	//it's a post-increment operation as to the codepoint, i.e., it gives the codepoint
	//starting at the initial position and only then moves the pointer forward
	$p = $codepoint_it->next();
}

echo "Now backwards\n";
$p = $codepoint_it->last();
while ($p != IntlBreakIterator::DONE) {
	$c = $codepoint_it->getLastCodePoint();
	if ($c > 0)
		var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint()));
	else
		var_dump($c);
	$p = $codepoint_it->previous();
}


?>
==DONE==
--EXPECT--
int(-1)
int(-1)
string(6) "U+0E15"
string(6) "U+0E31"
string(6) "U+0E27"
string(6) "U+0E2D"
string(6) "U+0E22"
string(6) "U+0E48"
string(6) "U+0E32"
string(6) "U+0E07"
string(6) "U+0E02"
string(6) "U+0E49"
string(6) "U+0E2D"
string(6) "U+0E04"
string(6) "U+0E27"
string(6) "U+0E32"
string(6) "U+0E21"
Now backwards
int(-1)
string(6) "U+0E21"
string(6) "U+0E32"
string(6) "U+0E27"
string(6) "U+0E04"
string(6) "U+0E2D"
string(6) "U+0E49"
string(6) "U+0E02"
string(6) "U+0E07"
string(6) "U+0E32"
string(6) "U+0E48"
string(6) "U+0E22"
string(6) "U+0E2D"
string(6) "U+0E27"
string(6) "U+0E31"
string(6) "U+0E15"
==DONE==