* revert r61258
authorMark A. Hershberger <mah@users.mediawiki.org>
Wed, 14 Jul 2010 17:34:18 +0000 (17:34 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Wed, 14 Jul 2010 17:34:18 +0000 (17:34 +0000)
* check if iconv extension is loaded and, if so, use it in UtfNormal::cleanUp()

includes/DjVuImage.php
includes/normal/UtfNormal.php

index f14d8d6..842b3a9 100644 (file)
@@ -251,13 +251,7 @@ class DjVuImage {
                        wfProfileOut( 'djvutxt' );
                        if( $retval == 0) {
                                # Get rid of invalid UTF-8, strip control characters
-                               if( is_callable( 'iconv' ) ) {
-                                       wfSuppressWarnings();
-                                       $txt = iconv( "UTF-8","UTF-8//IGNORE", $txt );
-                                       wfRestoreWarnings();
-                               } else {
-                                       $txt = UtfNormal::cleanUp( $txt );
-                               }
+                               $txt = UtfNormal::cleanUp( $txt );
                                $txt = preg_replace( "/[\013\035\037]/", "", $txt );
                                $reg = <<<EOR
                                        /\(page\s[\d-]*\s[\d-]*\s[\d-]*\s[\d-]*\s*"
index e1352fd..c34641b 100644 (file)
@@ -72,6 +72,13 @@ class UtfNormal {
         * @return string a clean, shiny, normalized UTF-8 string
         */
        static function cleanUp( $string ) {
+               if( extension_loaded( 'iconv' ) ) {
+                       wfSuppressWarnings();
+                       $ret = iconv( "UTF-8","UTF-8//IGNORE", $string );
+                       wfRestoreWarnings();
+                       return $ret;
+               }
+
                if( NORMALIZE_ICU ) {
                        # We exclude a few chars that ICU would not.
                        $string = preg_replace(