(bug 16885) Silence warnings about invalid characters in input string too with iconv
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Tue, 7 Jul 2009 09:56:53 +0000 (09:56 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Tue, 7 Jul 2009 09:56:53 +0000 (09:56 +0000)
languages/Language.php
languages/classes/LanguageEo.php

index 01c189e..2fa867a 100644 (file)
@@ -1467,8 +1467,17 @@ class Language {
        }
 
        function iconv( $in, $out, $string ) {
-               # For most languages, this is a wrapper for iconv
-               return iconv( $in, $out . '//IGNORE', $string );
+               # This is a wrapper for iconv in all languages except esperanto,
+               # which does some nasty x-conversions beforehand
+
+               # Even with //IGNORE iconv can whine about illegal characters in
+               # *input* string. We just ignore those too.
+               # REF: http://bugs.php.net/bug.php?id=37166
+               # REF: https://bugzilla.wikimedia.org/show_bug.cgi?id=16885
+               wfSuppressWarnings();
+               $text = iconv( $in, $out . '//IGNORE', $string );
+               wfRestoreWarnings();
+               return $text;
        }
 
        // callback functions for uc(), lc(), ucwords(), ucwordbreaks()
index c58d424..822a43f 100644 (file)
@@ -6,7 +6,6 @@
  */
 class LanguageEo extends Language {
        function iconv( $in, $out, $string ) {
-               # For most languages, this is a wrapper for iconv
                # Por multaj lingvoj, ĉi tiu nur voku la sisteman funkcion iconv()
                # Ni ankaŭ konvertu X-sistemajn surogotajn
                if( strcasecmp( $in, 'x' ) == 0 and strcasecmp( $out, 'utf-8' ) == 0) {
@@ -42,7 +41,7 @@ class LanguageEo extends Language {
                        return preg_replace( '/((?:[cghjsu]|\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'.
                          '|\xc5[\x9c\x9d\xac\xad])x*)/ei', 'strtr( "$1", $ux )', $string );
                }
-               return iconv( $in, $out, $string );
+               return parent::iconv( $in, $out, $string );
        }
 
        function checkTitleEncoding( $s ) {