From 1fadd47eb24c96d5b5156c623b8af0b3c11614b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Tue, 7 Jul 2009 09:56:53 +0000 Subject: [PATCH] (bug 16885) Silence warnings about invalid characters in input string too with iconv --- languages/Language.php | 13 +++++++++++-- languages/classes/LanguageEo.php | 3 +-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/languages/Language.php b/languages/Language.php index 01c189e848..2fa867a404 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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() diff --git a/languages/classes/LanguageEo.php b/languages/classes/LanguageEo.php index c58d424f55..822a43f718 100644 --- a/languages/classes/LanguageEo.php +++ b/languages/classes/LanguageEo.php @@ -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 ) { -- 2.20.1