[w3m-dev 03925] libwc + sinocode

Rei FURUKAWA <[email protected]>
Newsgroups gmane.comp.web.w3m.devel
Message-ID <[email protected]>
古川と申します。

w3m-m17n で、日本語だけの環境でも、中国語のページをもう少し
それっぽく見えるように、libwc の ucs -> jis のテーブルに、
sinocode の変換テーブルを組み込むようにしてみました。

(1) sinocode をインストールする
(2) w3m-m17n の libwc/map に、cd して、
(3) mk_jis_ucs_map.pl 実行の準備をする
        (EASTASIA/JIS/JIS*.TXT, jisx0213code.txtを置く)
(4) mk_jis_ucs_map.pl に添付の patch をあてる
(5) 添付した sino.pl を置く
(6) GB2312.TXT, BIG5.TXT を置く
(7) perl mk_jis_ucs_map.pl を実行

という具合にやると、sinocode の変換テーブルが組み込まれた
jisx0208x0212x0213_ucs.map ができます。


・読める文字が 1400 字ほど増えます
・sinocode の変換テーブルは、厳密に同じ文字を示すものでは
  ありません。
・このテーブルを組み入れても、なお、読めない文字は残ります。


-- 
Rei FURUKAWA 
[email protected]
mk_jis_ucs_map.patch (text/plain, 220 B)
--- ./mk_jis_ucs_map.pl.orig	Sun Jun 29 15:56:57 2003
+++ ./mk_jis_ucs_map.pl	Sat Jun 28 22:23:06 2003
@@ -140,6 +140,8 @@
 };
 EOF
 
+require 'sino.pl';
+
 @ucs = sort { $a <=> $b } keys %from_ucs;
 $nucs = @ucs + 0;
sino.pl (text/plain, 1 KB)
&sino("gb", "GB2312.TXT", 0x7f7f, [0xa1..0xfe]);
&sino("big", "BIG5.TXT", 0xffff, [0x40..0x7e, 0xa1..0xfe]);
1;

sub sino{
    my ($cod, $tbl, $mask, $ref) = @_;
    my $tmpfile = "sino.tmp";
    my %trans;
    local(*FH);

    open(FH, ">$tmpfile");
    for my $hi (0xa1..0xfe){
        for my $lo (@$ref){
            printf FH ("%02X%02X %c%c\n", $hi, $lo, $hi, $lo);
        }
    }
    close FH;

    open(FH, "sinocode -$cod $tmpfile -jis - |");
    while (defined(my $str = <FH>)){
        if ($str !~ /\xa2\xae/
            && $str =~ /^([\dA-F]{4}) ([\xa1-\xfe])([\xa1-\xfe])$/){
            $trans{sprintf("%04X", $mask & hex $1)} = 
                0x7f7f & ((ord $2) << 8 | ord $3);
        }
    }
    close FH;

    open(FH, $tbl);
    while (defined(my $str = <FH>)){
        if ($str =~ /^0x([\dA-F]{4})\s+0x([\dA-F]{4})/){
            if (defined(my $jis = $trans{$1})){
                my $ucs = hex $2;
                $from_ucs{$ucs} = $jis unless defined $from_ucs{$ucs};
            }
        }
    }
    close FH;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.