1
0
mirror of https://github.com/php/php-src.git synced 2026-03-27 17:52:16 +01:00
Files
archived-php-src/ext/mbstring/tests/023.inc
Moriyoshi Koizumi 7b3fb01072 Updated the test cases so that they use mb_regex_set_options.
Added a test for mb_regex_set_options.
2002-10-10 17:05:04 +00:00

24 lines
798 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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 = '([-]+) ([ あ-か]+)([か-な]+) ([わ-ん]+)$';
test_ereg( $enc, $pat, ' あおい かこな わゑん' );
test_ereg( $enc, $pat, ' うおか きか をゐ' );
}
foreach( $encs as $enc ) {
do_tests( $enc );
}
?>