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