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
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