From: Jarkko Hietaniemi Date: Sat, 9 Mar 2002 18:49:55 +0000 (+0000) Subject: Not everybody has Encode::HanExtra. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e1b390dd5c0537eb1ffbc6693d65bbe6c5a6e9cd;p=p5sagit%2Fp5-mst-13.2.git Not everybody has Encode::HanExtra. p4raw-id: //depot/perl@15135 --- diff --git a/ext/Encode/Encode.pm b/ext/Encode/Encode.pm index a279225..5d21184 100644 --- a/ext/Encode/Encode.pm +++ b/ext/Encode/Encode.pm @@ -57,27 +57,37 @@ our %winlatin2cp = ( 'Vietnamese' => 1258, ); -our %external_tables = ( - 'euc-cn' => 'Encode/CN.pm', - gb2312 => 'Encode/CN.pm', - gb12345 => 'Encode/CN.pm', - gbk => 'Encode/CN.pm', - cp936 => 'Encode/CN.pm', - 'iso-ir-165' => 'Encode/CN.pm', - 'euc-jp' => 'Encode/JP.pm', - shiftjis => 'Encode/JP.pm', - macjapan => 'Encode/JP.pm', - cp932 => 'Encode/JP.pm', - 'euc-kr' => 'Encode/KR.pm', - ksc5601 => 'Encode/KR.pm', - cp949 => 'Encode/KR.pm', - big5 => 'Encode/TW.pm', - 'big5-hkscs' => 'Encode/TW.pm', - cp950 => 'Encode/TW.pm', - gb18030 => 'Encode/CN.pm', # HanExtra - big5plus => 'Encode/TW.pm', # HanExtra - 'euc-tw', => 'Encode/TW.pm', # HanExtra -); +BEGIN { + our %external_tables = + ( + 'euc-cn' => 'Encode/CN.pm', + gb2312 => 'Encode/CN.pm', + gb12345 => 'Encode/CN.pm', + gbk => 'Encode/CN.pm', + cp936 => 'Encode/CN.pm', + 'iso-ir-165' => 'Encode/CN.pm', + 'euc-jp' => 'Encode/JP.pm', + shiftjis => 'Encode/JP.pm', + macjapan => 'Encode/JP.pm', + cp932 => 'Encode/JP.pm', + 'euc-kr' => 'Encode/KR.pm', + ksc5601 => 'Encode/KR.pm', + cp949 => 'Encode/KR.pm', + big5 => 'Encode/TW.pm', + 'big5-hkscs' => 'Encode/TW.pm', + cp950 => 'Encode/TW.pm', + ); + + eval 'require Encode::HanExtra'; + unless ($@) { + push %external_tables, + ( + gb18030 => 'Encode/CN.pm', # HanExtra + big5plus => 'Encode/TW.pm', # HanExtra + 'euc-tw', => 'Encode/TW.pm', # HanExtra + ); + } +} sub encodings {