summaryrefslogtreecommitdiff
path: root/ext/mbstring/tests/023.inc
blob: 923312efb8d93e973179c056c416690f7e099fdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
	mb_regex_set_options( '' );

	$encs = array( 'EUC-JP', 'Shift_JIS', 'SJIS', 'UTF-8' );

	function test_ereg( $test_enc, $pat, $str, $in_enc = 'EUC-JP' ) {
		mb_regex_encoding( $test_enc );
		$pat = mb_convert_encoding( $pat, $test_enc, $in_enc );
		$str = mb_convert_encoding( $str, $test_enc, $in_enc );

		printf( "(%d)%s\n", mb_ereg( $pat, $str, $reg ), ( is_array( $reg )? mb_convert_encoding( implode( ' ', $reg ), $in_enc, $test_enc ) : '' ) );
	} 
	function do_tests( $enc ) {
		test_ereg( $enc, 'abc ([a-z]+) ([a-z]+) ([a-z]+)$', "abc def ghi jkl" );
		$pat = '([a-z]+) ([ あ-か]+)([か-な]+) ([わ-ん]+)$'; 
		test_ereg( $enc, $pat, 'abc あおい かこな わゑん' );
		test_ereg( $enc, $pat, 'mzxfp うおか きか をゐ' );
	}

	foreach( $encs as $enc ) {
		do_tests( $enc );
	}
?>