Annotation of embedaddon/php/ext/iconv/tests/iconv_strrpos.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: iconv_strrpos()
3: --SKIPIF--
4: <?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
5: --INI--
6: iconv.internal_charset=ISO-8859-1
7: --FILE--
8: <?php
9: function my_error_handler($errno, $errmsg, $filename, $linenum, $vars)
10: {
11: echo "$errno: $errmsg\n";
12: }
13: set_error_handler('my_error_handler');
14: function foo($haystk, $needle, $to_charset = false, $from_charset = false)
15: {
16: if ($from_charset !== false) {
17: $haystk = iconv($from_charset, $to_charset, $haystk);
18: }
19: if ($to_charset !== false) {
20: var_dump(iconv_strlen($haystk, $to_charset));
21: var_dump(iconv_strrpos($haystk, $needle, $to_charset));
22: } else {
23: var_dump(iconv_strlen($haystk));
24: var_dump(iconv_strrpos($haystk, $needle));
25: }
26: }
27: foo("abecdbcdabcdef", "bcd");
28: foo(str_repeat("abcab", 60)."abcdb".str_repeat("adabc", 60), "abcd");
29: foo(str_repeat("あいうえお", 30)."いうおえあ".str_repeat("あいえおう", 30), "うお", "EUC-JP");
30:
31: for ($i = 0; $i <=6; ++$i) {
32: $str = str_repeat("あいうえお", 60).str_repeat('$', $i).str_repeat("あいえおう", 60);
33: foo($str, '$', "ISO-2022-JP", "EUC-JP");
34: }
35:
36: var_dump(iconv_strrpos("string", ""));
37: var_dump(iconv_strrpos("", "string"));
38:
39: ?>
40: --EXPECT--
41: int(14)
42: int(9)
43: int(605)
44: int(300)
45: int(305)
46: int(151)
47: int(600)
48: bool(false)
49: int(601)
50: int(300)
51: int(602)
52: int(301)
53: int(603)
54: int(302)
55: int(604)
56: int(303)
57: int(605)
58: int(304)
59: int(606)
60: int(305)
61: bool(false)
62: bool(false)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>