From: Brion Vibber Date: Tue, 5 Feb 2008 23:13:17 +0000 (+0000) Subject: While we're in there, let's remove a dependency on iconv(). Do the UTF-16 to ASCII... X-Git-Tag: 1.31.0-rc.0~49589 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=d3ddd6efdbfefa8065a2abcdbcb019b3effd209b;p=lhc%2Fweb%2Fwiklou.git While we're in there, let's remove a dependency on iconv(). Do the UTF-16 to ASCII merging in the XML checks manually. --- diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 8ba992560e..77a306214a 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -479,9 +479,17 @@ class MimeMagic { */ } - if ( $xml_type ) { - if ( $xml_type !== "UTF-8" && $xml_type !== "ASCII" ) { - $head = iconv( $xml_type, "ASCII//IGNORE", $head ); + if( $xml_type == 'UTF-16BE' || $xml_type == 'UTF-16LE' ) { + // Quick and dirty fold down to ASCII! + $pack = array( 'UTF-16BE' => 'n*', 'UTF-16LE' => 'v*' ); + $chars = unpack( $pack[$xml_type], substr( $head, 2 ) ); + $head = ''; + foreach( $chars as $codepoint ) { + if( $codepoint < 128 ) { + $head .= chr( $codepoint ); + } else { + $head .= '?'; + } } }