1--TEST--
2mb_ereg_search() stuff
3--EXTENSIONS--
4mbstring
5--SKIPIF--
6<?php
7function_exists('mb_ereg_search') or die("skip\n");
8?>
9--INI--
10output_handler=
11--FILE--
12<?php
13    mb_regex_set_options( '' );
14
15    $encs = array( 'EUC-JP', 'Shift_JIS', 'SJIS', 'UTF-8' );
16
17    function test_search( $test_enc, $str, $look_for, $opt, $in_enc = 'EUC-JP' ) {
18        mb_regex_encoding( $test_enc );
19        $str = mb_convert_encoding( $str, $test_enc, $in_enc );
20        $look_for = mb_convert_encoding( $look_for, $test_enc, $in_enc );
21        mb_ereg_search_init( $str, $look_for, $opt );
22        while ( mb_ereg_search_pos() ) {
23            $regs = mb_ereg_search_getregs();
24            array_shift( $regs );
25            printf( "(%s) (%d) %s\n", $test_enc, mb_ereg_search_getpos(), mb_convert_encoding( ( is_array( $regs ) ? implode( '-', $regs ): '' ), $in_enc, $test_enc ) );
26        }
27    }
28    function do_tests( $enc, $opt ) {
29        test_search( $enc, "�ϡ� ����\n", ' (��?�ϡ�?)[[:space:]]', $opt );
30        test_search( $enc, 'abcde abdeabcf anvfabc odu abcd ', '(ab[a-z]+)', $opt );
31    }
32
33    foreach( $encs as $enc ) {
34        do_tests( $enc, '' );
35        do_tests( $enc, 'x' );
36    }
37?>
38--EXPECT--
39(EUC-JP) (10) ����
40(EUC-JP) (5) abcde
41(EUC-JP) (14) abdeabcf
42(EUC-JP) (22) abc
43(EUC-JP) (31) abcd
44(EUC-JP) (5) �ϡ�
45(EUC-JP) (10) ����
46(EUC-JP) (5) abcde
47(EUC-JP) (14) abdeabcf
48(EUC-JP) (22) abc
49(EUC-JP) (31) abcd
50(Shift_JIS) (10) ����
51(Shift_JIS) (5) abcde
52(Shift_JIS) (14) abdeabcf
53(Shift_JIS) (22) abc
54(Shift_JIS) (31) abcd
55(Shift_JIS) (5) �ϡ�
56(Shift_JIS) (10) ����
57(Shift_JIS) (5) abcde
58(Shift_JIS) (14) abdeabcf
59(Shift_JIS) (22) abc
60(Shift_JIS) (31) abcd
61(SJIS) (10) ����
62(SJIS) (5) abcde
63(SJIS) (14) abdeabcf
64(SJIS) (22) abc
65(SJIS) (31) abcd
66(SJIS) (5) �ϡ�
67(SJIS) (10) ����
68(SJIS) (5) abcde
69(SJIS) (14) abdeabcf
70(SJIS) (22) abc
71(SJIS) (31) abcd
72(UTF-8) (14) ����
73(UTF-8) (5) abcde
74(UTF-8) (14) abdeabcf
75(UTF-8) (22) abc
76(UTF-8) (31) abcd
77(UTF-8) (7) �ϡ�
78(UTF-8) (14) ����
79(UTF-8) (5) abcde
80(UTF-8) (14) abdeabcf
81(UTF-8) (22) abc
82(UTF-8) (31) abcd
83