2002-10-08 02:02:05 +08:00
|
|
|
|
--TEST--
|
|
|
|
|
mb_ereg_search() stuff
|
|
|
|
|
--SKIPIF--
|
2002-10-30 16:06:52 +08:00
|
|
|
|
<?php
|
|
|
|
|
extension_loaded('mbstring') or die('skip mbstring not available');
|
2002-11-15 23:34:57 +08:00
|
|
|
|
function_exists('mb_ereg_search') or die("skip\n");
|
2002-10-30 16:06:52 +08:00
|
|
|
|
?>
|
2002-11-03 16:37:59 +08:00
|
|
|
|
--INI--
|
|
|
|
|
output_handler=
|
2002-10-08 02:02:05 +08:00
|
|
|
|
--FILE--
|
2002-10-22 03:19:05 +08:00
|
|
|
|
<?php
|
|
|
|
|
mb_regex_set_options( '' );
|
|
|
|
|
|
|
|
|
|
$encs = array( 'EUC-JP', 'Shift_JIS', 'SJIS', 'UTF-8' );
|
|
|
|
|
|
|
|
|
|
function test_search( $test_enc, $str, $look_for, $opt, $in_enc = 'EUC-JP' ) {
|
|
|
|
|
mb_regex_encoding( $test_enc );
|
|
|
|
|
$str = mb_convert_encoding( $str, $test_enc, $in_enc );
|
|
|
|
|
$look_for = mb_convert_encoding( $look_for, $test_enc, $in_enc );
|
|
|
|
|
mb_ereg_search_init( $str, $look_for, $opt );
|
|
|
|
|
while ( mb_ereg_search_pos() ) {
|
|
|
|
|
$regs = mb_ereg_search_getregs();
|
|
|
|
|
array_shift( $regs );
|
|
|
|
|
printf( "(%s) (%d) %s\n", $test_enc, mb_ereg_search_getpos(), mb_convert_encoding( ( is_array( $regs ) ? implode( '-', $regs ): '' ), $in_enc, $test_enc ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function do_tests( $enc, $opt ) {
|
|
|
|
|
test_search( $enc, "<22>ϡ<EFBFBD> <20><><EFBFBD><EFBFBD>\n", ' (<28><>?<3F>ϡ<EFBFBD>?)[[:space:]]', $opt );
|
|
|
|
|
test_search( $enc, 'abcde abdeabcf anvfabc odu abcd ', '(ab[a-z]+)', $opt );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach( $encs as $enc ) {
|
|
|
|
|
do_tests( $enc, '' );
|
|
|
|
|
do_tests( $enc, 'x' );
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
|
2002-10-08 02:02:05 +08:00
|
|
|
|
--EXPECT--
|
|
|
|
|
(EUC-JP) (10) <20><><EFBFBD><EFBFBD>
|
|
|
|
|
(EUC-JP) (5) abcde
|
|
|
|
|
(EUC-JP) (14) abdeabcf
|
|
|
|
|
(EUC-JP) (22) abc
|
|
|
|
|
(EUC-JP) (31) abcd
|
|
|
|
|
(EUC-JP) (5) <20>ϡ<EFBFBD>
|
|
|
|
|
(EUC-JP) (10) <20><><EFBFBD><EFBFBD>
|
|
|
|
|
(EUC-JP) (5) abcde
|
|
|
|
|
(EUC-JP) (14) abdeabcf
|
|
|
|
|
(EUC-JP) (22) abc
|
|
|
|
|
(EUC-JP) (31) abcd
|
|
|
|
|
(Shift_JIS) (10) <20><><EFBFBD><EFBFBD>
|
|
|
|
|
(Shift_JIS) (5) abcde
|
|
|
|
|
(Shift_JIS) (14) abdeabcf
|
|
|
|
|
(Shift_JIS) (22) abc
|
|
|
|
|
(Shift_JIS) (31) abcd
|
|
|
|
|
(Shift_JIS) (5) <20>ϡ<EFBFBD>
|
|
|
|
|
(Shift_JIS) (10) <20><><EFBFBD><EFBFBD>
|
|
|
|
|
(Shift_JIS) (5) abcde
|
|
|
|
|
(Shift_JIS) (14) abdeabcf
|
|
|
|
|
(Shift_JIS) (22) abc
|
|
|
|
|
(Shift_JIS) (31) abcd
|
|
|
|
|
(SJIS) (10) <20><><EFBFBD><EFBFBD>
|
|
|
|
|
(SJIS) (5) abcde
|
|
|
|
|
(SJIS) (14) abdeabcf
|
|
|
|
|
(SJIS) (22) abc
|
|
|
|
|
(SJIS) (31) abcd
|
|
|
|
|
(SJIS) (5) <20>ϡ<EFBFBD>
|
|
|
|
|
(SJIS) (10) <20><><EFBFBD><EFBFBD>
|
|
|
|
|
(SJIS) (5) abcde
|
|
|
|
|
(SJIS) (14) abdeabcf
|
|
|
|
|
(SJIS) (22) abc
|
|
|
|
|
(SJIS) (31) abcd
|
|
|
|
|
(UTF-8) (14) <20><><EFBFBD><EFBFBD>
|
|
|
|
|
(UTF-8) (5) abcde
|
|
|
|
|
(UTF-8) (14) abdeabcf
|
|
|
|
|
(UTF-8) (22) abc
|
|
|
|
|
(UTF-8) (31) abcd
|
|
|
|
|
(UTF-8) (7) <20>ϡ<EFBFBD>
|
|
|
|
|
(UTF-8) (14) <20><><EFBFBD><EFBFBD>
|
|
|
|
|
(UTF-8) (5) abcde
|
|
|
|
|
(UTF-8) (14) abdeabcf
|
|
|
|
|
(UTF-8) (22) abc
|
|
|
|
|
(UTF-8) (31) abcd
|