From 90050b9926ff1a9a2362c4f4d96e2b8dbaef9207 Mon Sep 17 00:00:00 2001 From: Platonides Date: Wed, 22 Dec 2010 21:44:05 +0000 Subject: [PATCH] Reimplement $cp1252Table avoiding th e5.3-only heredoc. --- maintenance/importUseModWikipedia.php | 305 ++++---------------------- 1 file changed, 43 insertions(+), 262 deletions(-) diff --git a/maintenance/importUseModWikipedia.php b/maintenance/importUseModWikipedia.php index 48c22e6890..c0d8dd7be6 100644 --- a/maintenance/importUseModWikipedia.php +++ b/maintenance/importUseModWikipedia.php @@ -94,264 +94,40 @@ class ImportUseModWikipedia extends Maintenance { var $FS, $FS1, $FS2, $FS3; var $FreeLinkPattern, $UrlPattern, $LinkPattern, $InterLinkPattern; - var $cp1252Table = << 0x20ac, +0x81 => 0x0081, +0x82 => 0x201a, +0x83 => 0x0192, +0x84 => 0x201e, +0x85 => 0x2026, +0x86 => 0x2020, +0x87 => 0x2021, +0x88 => 0x02c6, +0x89 => 0x2030, +0x8a => 0x0160, +0x8b => 0x2039, +0x8c => 0x0152, +0x8d => 0x008d, +0x8e => 0x017d, +0x8f => 0x008f, +0x90 => 0x0090, +0x91 => 0x2018, +0x92 => 0x2019, +0x93 => 0x201c, +0x94 => 0x201d, +0x95 => 0x2022, +0x96 => 0x2013, +0x97 => 0x2014, +0x98 => 0x02dc, +0x99 => 0x2122, +0x9a => 0x0161, +0x9b => 0x203a, +0x9c => 0x0153, +0x9d => 0x009d, +0x9e => 0x017e, +0x9f => 0x0178); + public function __construct() { parent::__construct(); $this->addOption( 'datadir', 'the value of $DataDir from wiki.cgi', true, true ); @@ -359,10 +135,15 @@ EOT; $this->initLinkPatterns(); $this->encodeMap = $this->decodeMap = array(); - foreach ( explode( "\n", $this->cp1252Table ) as $line ) { - list( $source, $dest ) = explode( "\t", $line ); - $sourceChar = chr( base_convert( substr( $source, 2 ), 16, 10 ) ); - $destChar = codepointToUtf8( base_convert( substr( $dest, 2 ), 16, 10 ) ); + + for ($source = 0; $source <= 0xff; $source++) { + if ( isset( $this->cp1252Table[$source] ) ) { + $dest = $this->cp1252Table[$source]; + } else { + $dest = $source; + } + $sourceChar = chr( $source ); + $destChar = codepointToUtf8( $dest ); $this->encodeMap[$sourceChar] = $destChar; $this->decodeMap[$destChar] = $sourceChar; } -- 2.20.1