Create a Special:Redirect page.
[lhc/web/wiklou.git] / includes / normal / UtfNormalTest.php
index 22e6471..5118366 100644 (file)
  * @ingroup UtfNormal
  */
 
+if( PHP_SAPI != 'cli' ) {
+       die( "Run me from the command line please.\n" );
+}
+
 $verbose = true;
 #define( 'PRETTY_UTF8', true );
 
 if( defined( 'PRETTY_UTF8' ) ) {
        function pretty( $string ) {
-               return preg_replace( '/([\x00-\xff])/e',
-                       'sprintf("%02X", ord("$1"))',
-                       $string );
+               return strtoupper( bin2hex( $string ) );
        }
 } else {
        /**
@@ -40,9 +42,7 @@ if( defined( 'PRETTY_UTF8' ) ) {
         * @return string
         */
        function pretty( $string ) {
-               return trim( preg_replace( '/(.)/use',
-                       'sprintf("%04X ", utf8ToCodepoint("$1"))',
-                       $string ) );
+               return strtoupper( utf8ToHexSequence( $string ) );
        }
 }
 
@@ -54,10 +54,6 @@ require_once 'UtfNormalDefines.php';
 require_once 'UtfNormalUtil.php';
 require_once 'UtfNormal.php';
 
-if( PHP_SAPI != 'cli' ) {
-       die( "Run me from the command line please.\n" );
-}
-
 $in = fopen("NormalizationTest.txt", "rt");
 if( !$in ) {
        print "Couldn't open NormalizationTest.txt -- can't run tests.\n";