mirror of
https://github.com/php/php-src.git
synced 2024-10-14 04:52:33 +00:00
22 lines
768 B
PHP
22 lines
768 B
PHP
<?php
|
||
$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 );
|
||
}
|
||
?>
|