require_once 'UtfNormal.php';
mb_internal_encoding( "utf-8" );
+$verbose = false;
#$verbose = true;
if( php_sapi_name() != 'cli' ) {
die( "Run me from the command line please.\n" );
if( !$in ) {
print "Couldn't open UTF-8-test.txt -- can't run tests.\n";
print "If necessary, manually download this file. It can be obtained at\n";
- print "http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt";
+ print "http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt\n";
exit(-1);
}
if( !$columns ) {
print "Something seems to be wrong; couldn't extract line length.\n";
print "Check that UTF-8-test.txt was downloaded correctly from\n";
- print "http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt";
+ print "http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt\n";
exit(-1);
}
if( in_array( $test, $longTests ) ) {
$line = fgets( $in );
for( $line = fgets( $in ); !preg_match( '/^\s+\|/', $line ); $line = fgets( $in ) ) {
- testLine( $test, $line, $total, $success, $failed );
+ testLine( $test, $line, $total, $success, $failed, $columns, $exceptions, $verbose );
}
} else {
- testLine( $test, $line, $total, $success, $failed );
+ testLine( $test, $line, $total, $success, $failed, $columns, $exceptions, $verbose );
}
}
}
exit (0);
-function testLine( $test, $line, &$total, &$success, &$failed ) {
+function testLine( $test, $line, &$total, &$success, &$failed, $columns, $exceptions, $verbose ) {
$stripped = $line;
UtfNormal::quickisNFCVerify( $stripped );
$len = strlen( substr( $stripped, 0, strpos( $stripped, '|' ) ) );
}
- global $columns;
$ok = $same ^ ($test >= 3 );
- global $exceptions;
$ok ^= in_array( $test, $exceptions );
$ok &= ($columns == $len);
} else {
$failed++;
}
- global $verbose;
+
if( $verbose || !$ok ) {
print str_replace( "\n", "$len\n", $stripped );
}