libjcode-perl-2.13.orig/0040755000076500017510000000000007165260473014150 5ustar kamopkfootlibjcode-perl-2.13.orig/jcode.pl-2.130100644000076500017510000005114507165137364016157 0ustar kamopkfootpackage jcode; ;###################################################################### ;# ;# jcode.pl: Perl library for Japanese character code conversion ;# ;# Copyright (c) 1995-2000 Kazumasa Utashiro ;# Internet Initiative Japan Inc. ;# 3-13 Kanda Nishiki-cho, Chiyoda-ku, Tokyo 101-0054, Japan ;# ;# Copyright (c) 1992,1993,1994 Kazumasa Utashiro ;# Software Research Associates, Inc. ;# ;# Use and redistribution for ANY PURPOSE are granted as long as all ;# copyright notices are retained. Redistribution with modification ;# is allowed provided that you make your modified version obviously ;# distinguishable from the original one. THIS SOFTWARE IS PROVIDED ;# BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES ARE ;# DISCLAIMED. ;# ;# Original version was developed under the name of srekcah@sra.co.jp ;# February 1992 and it was called kconv.pl at the beginning. This ;# address was a pen name for group of individuals and it is no longer ;# valid. ;# ;# The latest version is available here: ;# ;# ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/ ;# ;; $rcsid = q$Id: jcode.pl,v 2.13 2000/09/29 16:10:05 utashiro Exp $; ;# ;###################################################################### ;# ;# PERL4 INTERFACE: ;# ;# &jcode'getcode(*line) ;# Return 'jis', 'sjis', 'euc' or undef according to ;# Japanese character code in $line. Return 'binary' if ;# the data has non-character code. ;# ;# When evaluated in array context, it returns a list ;# contains two items. First value is the number of ;# characters which matched to the expected code, and ;# second value is the code name. It is useful if and ;# only if the number is not 0 and the code is undef; ;# that case means it couldn't tell 'euc' or 'sjis' ;# because the evaluation score was exactly same. This ;# interface is too tricky, though. ;# ;# Code detection between euc and sjis is very difficult ;# or sometimes impossible or even lead to wrong result ;# when it includes JIS X0201 KANA characters. So JIS ;# X0201 KANA is ignored for automatic code detection. ;# ;# &jcode'convert(*line, $ocode [, $icode [, $option]]) ;# Convert the contents of $line to the specified ;# Japanese code given in the second argument $ocode. ;# $ocode can be any of "jis", "sjis" or "euc", or use ;# "noconv" when you don't want the code conversion. ;# Input code is recognized automatically from the line ;# itself when $icode is not supplied (JIS X0201 KANA is ;# ignored in code detection. See the above descripton ;# of &getcode). $icode also can be specified, but ;# xxx2yyy routine is more efficient when both codes are ;# known. ;# ;# It returns the code of input string in scalar context, ;# and a list of pointer of convert subroutine and the ;# input code in array context. ;# ;# Japanese character code JIS X0201, X0208, X0212 and ;# ASCII code are supported. X0212 characters can not be ;# represented in SJIS and they will be replased by ;# "geta" character when converted to SJIS. ;# ;# See next paragraph for $option parameter. ;# ;# &jcode'xxx2yyy(*line [, $option]) ;# Convert the Japanese code from xxx to yyy. String xxx ;# and yyy are any convination from "jis", "euc" or ;# "sjis". They return *approximate* number of converted ;# bytes. So return value 0 means the line was not ;# converted at all. ;# ;# Optional parameter $option is used to specify optional ;# conversion method. String "z" is for JIS X0201 KANA ;# to X0208 KANA, and "h" is for reverse. ;# ;# $jcode'convf{'xxx', 'yyy'} ;# The value of this associative array is pointer to the ;# subroutine jcode'xxx2yyy(). ;# ;# &jcode'to($ocode, $line [, $icode [, $option]]) ;# &jcode'jis($line [, $icode [, $option]]) ;# &jcode'euc($line [, $icode [, $option]]) ;# &jcode'sjis($line [, $icode [, $option]]) ;# These functions are prepared for easy use of ;# call/return-by-value interface. You can use these ;# funcitons in s///e operation or any other place for ;# convenience. ;# ;# &jcode'jis_inout($in, $out) ;# Set or inquire JIS start and end sequences. Default ;# is "ESC-$-B" and "ESC-(-B". If you supplied only one ;# character, "ESC-$" or "ESC-(" is prepended for each ;# character respectively. Acutually "ESC-(-B" is not a ;# sequence to end JIS code but a sequence to start ASCII ;# code set. So `in' and `out' are somewhat misleading. ;# ;# &jcode'get_inout($string) ;# Get JIS start and end sequences from $string. ;# ;# &jcode'cache() ;# &jcode'nocache() ;# &jcode'flush() ;# Usually, converted character is cached in memory to ;# avoid same calculations have to be done many times. ;# To disable this caching, call &jcode'nocache(). It ;# can be revived by &jcode'cache() and cache is flushed ;# by calling &jcode'flush(). &cache() and &nocache() ;# functions return previous caching state. ;# ;# --------------------------------------------------------------- ;# ;# &jcode'h2z_xxx(*line) ;# JIS X0201 KANA (so-called Hankaku-KANA) to X0208 KANA ;# (Zenkaku-KANA) code conversion routine. String xxx is ;# any of "jis", "sjis" and "euc". From the difficulty ;# of recognizing code set from 1-byte KATAKANA string, ;# automatic code recognition is not supported. ;# ;# &jcode'z2h_xxx(*line) ;# X0208 to X0201 KANA code conversion routine. String ;# xxx is any of "jis", "sjis" and "euc". ;# ;# $jcode'z2hf{'xxx'} ;# $jcode'h2zf{'xxx'} ;# These are pointer to the corresponding function just ;# as $jcode'convf. ;# ;# --------------------------------------------------------------- ;# ;# &jcode'tr(*line, $from, $to [, $option]) ;# &jcode'tr emulates tr operator for 2 byte code. Only 'd' ;# is interpreted as an option. ;# ;# Range operator like `A-Z' for 2 byte code is partially ;# supported. Code must be JIS or EUC, and first byte ;# have to be same on first and last character. ;# ;# CAUTION: Handling range operator is a kind of trick ;# and it is not perfect. So if you need to transfer `-' ;# character, please be sure to put it at the beginning ;# or the end of $from and $to strings. ;# ;# &jcode'trans($line, $from, $to [, $option) ;# Same as &jcode'tr but accept string and return string ;# after translation. ;# ;# --------------------------------------------------------------- ;# ;# &jcode'init() ;# Initialize the variables used in this package. You ;# don't have to call this when using jocde.pl by `do' or ;# `require' interface. Call it first if you embedded ;# the jcode.pl at the end of your script. ;# ;###################################################################### ;# ;# PERL5 INTERFACE: ;# ;# Current jcode.pl is written in Perl 4 but it is possible to use ;# from Perl 5 using `references'. Fully perl5 capable version is ;# future issue. ;# ;# Since lexical variable is not a subject of typeglob, *string style ;# call doesn't work if the variable is declared as `my'. Same thing ;# happens to special variable $_ if the perl is compiled to use ;# thread capability. So using reference is generally recommented to ;# avoid the mysterious error. ;# ;# jcode::getcode(\$line) ;# jcode::convert(\$line, $ocode [, $icode [, $option]]) ;# jcode::xxx2yyy(\$line [, $option]) ;# &{$jcode::convf{'xxx', 'yyy'}}(\$line) ;# jcode::to($ocode, $line [, $icode [, $option]]) ;# jcode::jis($line [, $icode [, $option]]) ;# jcode::euc($line [, $icode [, $option]]) ;# jcode::sjis($line [, $icode [, $option]]) ;# jcode::jis_inout($in, $out) ;# jcode::get_inout($string) ;# jcode::cache() ;# jcode::nocache() ;# jcode::flush() ;# jcode::h2z_xxx(\$line) ;# jcode::z2h_xxx(\$line) ;# &{$jcode::z2hf{'xxx'}}(\$line) ;# &{$jcode::h2zf{'xxx'}}(\$line) ;# jcode::tr(\$line, $from, $to [, $option]) ;# jcode::trans($line, $from, $to [, $option) ;# jcode::init() ;# ;###################################################################### ;# ;# SAMPLES ;# ;# Convert any Kanji code to JIS and print each line with code name. ;# ;# while (defined($s = <>)) { ;# $code = &jcode'convert(*s, 'jis'); ;# print $code, "\t", $s; ;# } ;# ;# Convert all lines to JIS according to the first recognized line. ;# ;# while (defined($s = <>)) { ;# print, next unless $s =~ /[\033\200-\377]/; ;# (*f, $icode) = &jcode'convert(*s, 'jis'); ;# print; ;# defined(&f) || next; ;# while (<>) { &f(*s); print; } ;# last; ;# } ;# ;# The safest way of JIS conversion. ;# ;# while (defined($s = <>)) { ;# ($matched, $icode) = &jcode'getcode(*s); ;# if (@buf == 0 && $matched == 0) { ;# print $s; ;# next; ;# } ;# push(@buf, $s); ;# next unless $icode; ;# while (defined($s = shift(@buf))) { ;# &jcode'convert(*s, 'jis', $icode); ;# print $s; ;# } ;# while (defined($s = <>)) { ;# &jcode'convert(*s, 'jis', $icode); ;# print $s; ;# } ;# last; ;# } ;# print @buf if @buf; ;# ;###################################################################### ;# ;# Call initialize function if it is not called yet. This may sound ;# strange but it makes easy to embed the jcode.pl at the end of ;# script. Call &jcode'init at the beginning of the script in that ;# case. ;# &init unless defined $version; ;# ;# Initialize variables. ;# sub init { $version = $rcsid =~ /,v ([\d.]+)/ ? $1 : 'unknown'; $re_bin = '[\000-\006\177\377]'; $re_jis0208_1978 = '\e\$\@'; $re_jis0208_1983 = '\e\$B'; $re_jis0208_1990 = '\e&\@\e\$B'; $re_jis0208 = "$re_jis0208_1978|$re_jis0208_1983|$re_jis0208_1990"; $re_jis0212 = '\e\$\(D'; $re_jp = "$re_jis0208|$re_jis0212"; $re_asc = '\e\([BJ]'; $re_kana = '\e\(I'; $esc_0208 = "\e\$B"; $esc_0212 = "\e\$(D"; $esc_asc = "\e(B"; $esc_kana = "\e(I"; $re_sjis_c = '[\201-\237\340-\374][\100-\176\200-\374]'; $re_sjis_kana = '[\241-\337]'; $re_euc_c = '[\241-\376][\241-\376]'; $re_euc_kana = '\216[\241-\337]'; $re_euc_0212 = '\217[\241-\376][\241-\376]'; # Use `geta' for undefined character code $undef_sjis = "\x81\xac"; $cache = 1; # X0201 -> X0208 KANA conversion table. Looks weird? Not that # much. This is simply JIS text without escape sequences. ($h2z_high = $h2z = <<'__TABLE_END__') =~ tr/\041-\176/\241-\376/; ! !# $ !" % !& " !V # !W ^ !+ _ !, 0 !< ' %! ( %# ) %% * %' + %) , %c - %e . %g / %C 1 %" 2 %$ 3 %& 4 %( 5 %* 6 %+ 7 %- 8 %/ 9 %1 : %3 6^ %, 7^ %. 8^ %0 9^ %2 :^ %4 ; %5 < %7 = %9 > %; ? %= ;^ %6 <^ %8 =^ %: >^ %< ?^ %> @ %? A %A B %D C %F D %H @^ %@ A^ %B B^ %E C^ %G D^ %I E %J F %K G %L H %M I %N J %O K %R L %U M %X N %[ J^ %P K^ %S L^ %V M^ %Y N^ %\ J_ %Q K_ %T L_ %W M_ %Z N_ %] O %^ P %_ Q %` R %a S %b T %d U %f V %h W %i X %j Y %k Z %l [ %m \ %o ] %s & %r 3^ %t __TABLE_END__ %h2z = split(/\s+/, $h2z . $h2z_high); %z2h = reverse %h2z; $convf{'jis' , 'jis' } = *jis2jis; $convf{'jis' , 'sjis'} = *jis2sjis; $convf{'jis' , 'euc' } = *jis2euc; $convf{'euc' , 'jis' } = *euc2jis; $convf{'euc' , 'sjis'} = *euc2sjis; $convf{'euc' , 'euc' } = *euc2euc; $convf{'sjis' , 'jis' } = *sjis2jis; $convf{'sjis' , 'sjis'} = *sjis2sjis; $convf{'sjis' , 'euc' } = *sjis2euc; $h2zf{'jis' } = *h2z_jis; $z2hf{'jis' } = *z2h_jis; $h2zf{'euc' } = *h2z_euc; $z2hf{'euc' } = *z2h_euc; $h2zf{'sjis'} = *h2z_sjis; $z2hf{'sjis'} = *z2h_sjis; } ;# ;# Set escape sequences which should be put before and after Japanese ;# (JIS X0208) string. ;# sub jis_inout { $esc_0208 = shift || $esc_0208; $esc_0208 = "\e\$$esc_0208" if length($esc_0208) == 1; $esc_asc = shift || $esc_asc; $esc_asc = "\e\($esc_asc" if length($esc_asc) == 1; ($esc_0208, $esc_asc); } ;# ;# Get JIS in and out sequences from the string. ;# sub get_inout { local($esc_0208, $esc_asc); $_[$[] =~ /($re_jis0208)/o && ($esc_0208 = $1); $_[$[] =~ /($re_asc)/o && ($esc_asc = $1); ($esc_0208, $esc_asc); } ;# ;# Recognize character code. ;# sub getcode { local(*s) = @_; local($matched, $code); if ($s !~ /[\e\200-\377]/) { # not Japanese $matched = 0; $code = undef; } # 'jis' elsif ($s =~ /$re_jp|$re_asc|$re_kana/o) { $matched = 1; $code = 'jis'; } elsif ($s =~ /$re_bin/o) { # 'binary' $matched = 0; $code = 'binary'; } else { # should be 'euc' or 'sjis' local($sjis, $euc) = (0, 0); while ($s =~ /(($re_sjis_c)+)/go) { $sjis += length($1); } while ($s =~ /(($re_euc_c|$re_euc_kana|$re_euc_0212)+)/go) { $euc += length($1); } $matched = &max($sjis, $euc); $code = ('euc', undef, 'sjis')[($sjis<=>$euc) + $[ + 1]; } wantarray ? ($matched, $code) : $code; } sub max { $_[ $[ + ($_[ $[ ] < $_[ $[ + 1 ]) ]; } ;# ;# Convert any code to specified code. ;# sub convert { local(*s, $ocode, $icode, $opt) = @_; return (undef, undef) unless $icode = $icode || &getcode(*s); return (undef, $icode) if $icode eq 'binary'; $ocode = 'jis' unless $ocode; $ocode = $icode if $ocode eq 'noconv'; local(*f) = $convf{$icode, $ocode}; &f(*s, $opt); wantarray ? (*f, $icode) : $icode; } ;# ;# Easy return-by-value interfaces. ;# sub jis { &to('jis', @_); } sub euc { &to('euc', @_); } sub sjis { &to('sjis', @_); } sub to { local($ocode, $s, $icode, $opt) = @_; &convert(*s, $ocode, $icode, $opt); $s; } sub what { local($s) = @_; &getcode(*s); } sub trans { local($s) = shift; &tr(*s, @_); $s; } ;# ;# SJIS to JIS ;# sub sjis2jis { local(*s, $opt, $n) = @_; &sjis2sjis(*s, $opt) if $opt; $s =~ s/(($re_sjis_c|$re_sjis_kana)+)/&_sjis2jis($1) . $esc_asc/geo; $n; } sub _sjis2jis { local($s) = shift; $s =~ s/(($re_sjis_c)+|($re_sjis_kana)+)/&__sjis2jis($1)/geo; $s; } sub __sjis2jis { local($s) = shift; if ($s =~ /^$re_sjis_kana/o) { $n += $s =~ tr/\241-\337/\041-\137/; $esc_kana . $s; } else { $n += $s =~ s/($re_sjis_c)/$s2e{$1}||&s2e($1)/geo; $s =~ tr/\241-\376/\041-\176/; $esc_0208 . $s; } } ;# ;# EUC to JIS ;# sub euc2jis { local(*s, $opt, $n) = @_; &euc2euc(*s, $opt) if $opt; $s =~ s/(($re_euc_c|$re_euc_kana|$re_euc_0212)+)/ &_euc2jis($1) . $esc_asc /geo; $n; } sub _euc2jis { local($s) = shift; $s =~ s/(($re_euc_c)+|($re_euc_kana)+|($re_euc_0212)+)/&__euc2jis($1)/geo; $s; } sub __euc2jis { local($s) = shift; local($esc); if ($s =~ tr/\216//d) { $esc = $esc_kana; } elsif ($s =~ tr/\217//d) { $esc = $esc_0212; } else { $esc = $esc_0208; } $n += $s =~ tr/\241-\376/\041-\176/; $esc . $s; } ;# ;# JIS to EUC ;# sub jis2euc { local(*s, $opt, $n) = @_; $s =~ s/($re_jp|$re_asc|$re_kana)([^\e]*)/&_jis2euc($1,$2)/geo; &euc2euc(*s, $opt) if $opt; $n; } sub _jis2euc { local($esc, $s) = @_; if ($esc !~ /^$re_asc/o) { $n += $s =~ tr/\041-\176/\241-\376/; if ($esc =~ /^$re_kana/o) { $s =~ s/([\241-\337])/\216$1/g; } elsif ($esc =~ /^$re_jis0212/o) { $s =~ s/([\241-\376][\241-\376])/\217$1/g; } } $s; } ;# ;# JIS to SJIS ;# sub jis2sjis { local(*s, $opt, $n) = @_; &jis2jis(*s, $opt) if $opt; $s =~ s/($re_jp|$re_asc|$re_kana)([^\e]*)/&_jis2sjis($1,$2)/geo; $n; } sub _jis2sjis { local($esc, $s) = @_; if ($esc =~ /^$re_jis0212/o) { $s =~ s/../$undef_sjis/g; $n = length; } elsif ($esc !~ /^$re_asc/o) { $n += $s =~ tr/\041-\176/\241-\376/; if ($esc =~ /^$re_jp/o) { $s =~ s/($re_euc_c)/$e2s{$1}||&e2s($1)/geo; } } $s; } ;# ;# SJIS to EUC ;# sub sjis2euc { local(*s, $opt,$n) = @_; $n = $s =~ s/($re_sjis_c|$re_sjis_kana)/$s2e{$1}||&s2e($1)/geo; &euc2euc(*s, $opt) if $opt; $n; } sub s2e { local($c1, $c2, $code); ($c1, $c2) = unpack('CC', $code = shift); if (0xa1 <= $c1 && $c1 <= 0xdf) { $c2 = $c1; $c1 = 0x8e; } elsif (0x9f <= $c2) { $c1 = $c1 * 2 - ($c1 >= 0xe0 ? 0xe0 : 0x60); $c2 += 2; } else { $c1 = $c1 * 2 - ($c1 >= 0xe0 ? 0xe1 : 0x61); $c2 += 0x60 + ($c2 < 0x7f); } if ($cache) { $s2e{$code} = pack('CC', $c1, $c2); } else { pack('CC', $c1, $c2); } } ;# ;# EUC to SJIS ;# sub euc2sjis { local(*s, $opt,$n) = @_; &euc2euc(*s, $opt) if $opt; $n = $s =~ s/($re_euc_c|$re_euc_kana|$re_euc_0212)/$e2s{$1}||&e2s($1)/geo; } sub e2s { local($c1, $c2, $code); ($c1, $c2) = unpack('CC', $code = shift); if ($c1 == 0x8e) { # SS2 return substr($code, 1, 1); } elsif ($c1 == 0x8f) { # SS3 return $undef_sjis; } elsif ($c1 % 2) { $c1 = ($c1>>1) + ($c1 < 0xdf ? 0x31 : 0x71); $c2 -= 0x60 + ($c2 < 0xe0); } else { $c1 = ($c1>>1) + ($c1 < 0xdf ? 0x30 : 0x70); $c2 -= 2; } if ($cache) { $e2s{$code} = pack('CC', $c1, $c2); } else { pack('CC', $c1, $c2); } } ;# ;# JIS to JIS, SJIS to SJIS, EUC to EUC ;# sub jis2jis { local(*s, $opt) = @_; $s =~ s/$re_jis0208/$esc_0208/go; $s =~ s/$re_asc/$esc_asc/go; &h2z_jis(*s) if $opt =~ /z/; &z2h_jis(*s) if $opt =~ /h/; } sub sjis2sjis { local(*s, $opt) = @_; &h2z_sjis(*s) if $opt =~ /z/; &z2h_sjis(*s) if $opt =~ /h/; } sub euc2euc { local(*s, $opt) = @_; &h2z_euc(*s) if $opt =~ /z/; &z2h_euc(*s) if $opt =~ /h/; } ;# ;# Cache control functions ;# sub cache { ($cache, $cache = 1)[$[]; } sub nocache { ($cache, $cache = 0)[$[]; } sub flushcache { undef %e2s; undef %s2e; } ;# ;# X0201 -> X0208 KANA conversion routine ;# sub h2z_jis { local(*s, $n) = @_; if ($s =~ s/$re_kana([^\e]*)/$esc_0208 . &_h2z_jis($1)/geo) { 1 while $s =~ s/(($re_jis0208)[^\e]*)($re_jis0208)/$1/o; } $n; } sub _h2z_jis { local($s) = @_; $n += $s =~ s/(([\041-\137])([\136\137])?)/ $h2z{$1} || $h2z{$2} . $h2z{$3} /ge; $s; } sub h2z_euc { local(*s) = @_; $s =~ s/\216([\241-\337])(\216([\336\337]))?/ $h2z{"$1$3"} || $h2z{$1} . $h2z{$3} /ge; } sub h2z_sjis { local(*s, $n) = @_; $s =~ s/(($re_sjis_c)+)|(([\241-\337])([\336\337])?)/ $1 || ($n++, $h2z{$3} ? $e2s{$h2z{$3}} || &e2s($h2z{$3}) : &e2s($h2z{$4}) . ($5 && &e2s($h2z{$5}))) /geo; $n; } ;# ;# X0208 -> X0201 KANA conversion routine ;# sub z2h_jis { local(*s, $n) = @_; $s =~ s/($re_jis0208)([^\e]+)/&_z2h_jis($2)/geo; $n; } sub _z2h_jis { local($s) = @_; $s =~ s/((\%[!-~]|![\#\"&VW+,<])+|([^!%][!-~]|![^\#\"&VW+,<])+)/ &__z2h_jis($1) /ge; $s; } sub __z2h_jis { local($s) = @_; return $esc_0208 . $s unless $s =~ /^%/ || $s =~ /^![\#\"&VW+,<]/; $n += length($s) / 2; $s =~ s/(..)/$z2h{$1}/g; $esc_kana . $s; } sub z2h_euc { local(*s, $n) = @_; &init_z2h_euc unless defined %z2h_euc; $s =~ s/($re_euc_c|$re_euc_kana)/ $z2h_euc{$1} ? ($n++, $z2h_euc{$1}) : $1 /geo; $n; } sub z2h_sjis { local(*s, $n) = @_; &init_z2h_sjis unless defined %z2h_sjis; $s =~ s/($re_sjis_c)/$z2h_sjis{$1} ? ($n++, $z2h_sjis{$1}) : $1/geo; $n; } ;# ;# Initializing JIS X0208 to X0201 KANA table for EUC and SJIS. This ;# can be done in &init but it's not worth doing. Similarly, ;# precalculated table is not worth to occupy the file space and ;# reduce the readability. The author personnaly discourages to use ;# X0201 Kana character in the any situation. ;# sub init_z2h_euc { local($k, $s); while (($k, $s) = each %z2h) { $s =~ s/([\241-\337])/\216$1/g && ($z2h_euc{$k} = $s); } } sub init_z2h_sjis { local($s, $v); while (($s, $v) = each %z2h) { $s =~ /[\200-\377]/ && ($z2h_sjis{&e2s($s)} = $v); } } ;# ;# TR function for 2-byte code ;# sub tr { # $prev_from, $prev_to, %table are persistent variables local(*s, $from, $to, $opt) = @_; local(@from, @to); local($jis, $n) = (0, 0); $jis++, &jis2euc(*s) if $s =~ /$re_jp|$re_asc|$re_kana/o; $jis++ if $to =~ /$re_jp|$re_asc|$re_kana/o; if (!defined($prev_from) || $from ne $prev_from || $to ne $prev_to) { ($prev_from, $prev_to) = ($from, $to); undef %table; &_maketable; } $s =~ s/([\200-\377][\000-\377]|[\000-\377])/ defined($table{$1}) && ++$n ? $table{$1} : $1 /ge; &euc2jis(*s) if $jis; $n; } sub _maketable { local($ascii) = '(\\\\[\\-\\\\]|[\0-\133\135-\177])'; &jis2euc(*to) if $to =~ /$re_jp|$re_asc|$re_kana/o; &jis2euc(*from) if $from =~ /$re_jp|$re_asc|$re_kana/o; grep(s/(([\200-\377])[\200-\377]-\2[\200-\377])/&_expnd2($1)/ge, $from, $to); grep(s/($ascii-$ascii)/&_expnd1($1)/geo, $from, $to); @to = $to =~ /[\200-\377][\000-\377]|[\000-\377]/g; @from = $from =~ /[\200-\377][\000-\377]|[\000-\377]/g; push(@to, ($opt =~ /d/ ? '' : $to[$#to]) x (@from - @to)) if @to < @from; @table{@from} = @to; } sub _expnd1 { local($s) = @_; $s =~ s/\\(.)/$1/g; local($c1, $c2) = unpack('CxC', $s); if ($c1 <= $c2) { for ($s = ''; $c1 <= $c2; $c1++) { $s .= pack('C', $c1); } } $s; } sub _expnd2 { local($s) = @_; local($c1, $c2, $c3, $c4) = unpack('CCxCC', $s); if ($c1 == $c3 && $c2 <= $c4) { for ($s = ''; $c2 <= $c4; $c2++) { $s .= pack('CC', $c1, $c2); } } $s; } 1; libjcode-perl-2.13.orig/jcode.pl-history0100644000076500017510000003744407031453034017266 0ustar kamopkfoot============================================================================== 2.11 (1999/12/26 17:16:47) ============================================================================== Message-ID: <19991227024224G.utashiro@iij.ad.jp> Mime-Version: 1.0 X-Dispatcher: imput version 991025(IM133) Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_Dec_27_02:41:53_1999_197)--" Content-Transfer-Encoding: 7bit Subject: jcode.pl-2.11 released From: Kazumasa Utashiro Newsgroups: fj.comp.lang.perl Date: 27 Dec 1999 02:42:24 +0900 X-Mailer: Mew version 1.95b3 on Emacs 19.28 / Mule 2.3 (SUETSUMUHANA) Path: news3.iij.ad.jp!not-for-mail Organization: Internet Initiative Japan Inc., Tokyo, JAPAN ----Next_Part(Mon_Dec_27_02:41:53_1999_197)-- Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit jcode.pl $B$,(B thread $B$rM-8z$K$7$?(B perl5 $B$GF0:n$7$J$$$H$$$&LdBj$,0JA0$+$i(B $B;XE&$5$l$F$$$^$7$?!#$=$l$KBP1~$7$?%P!<%8%g%s$r(B 2.11 $B$H$7$F%j%j!<%9CW$7(B $B$^$9!#(B ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/jcode.pl-2.11 Thread $B5!G=$,M-8z$K$7$F(B (-Dusethread) perl5 $B$,%3%s%Q%$%k$5$l$F$$$k>l9g!"(B $BJQ?t(B $_ $B$,%l%-%7%+%k%9%3!<%W$r;}$A!"(Btypeglob $B$NBP>]$K$J$i$J$/$J$j$^$9!#(B $B:#$^$G$O!"FbIt$G(B local(*_) = shift $B$N$h$&$KFCo$NJQ?t$G=hM}$9$k$h$&$KJQ(B $B99$7$^$7$?!#(B $B$?$@$7!"8F$S=P$7;~$K(B jcode::convert(*_, 'jis'); $B$N$h$&$K(B typeglob $B$r;H$&$H!"F1$8LdBj$N1F6A$rl9g$K$O!":#2s$NJQ(B $B99$K$h$k1F6A$O$"$j$^$;$s!#(B --utashiro ----Next_Part(Mon_Dec_27_02:41:53_1999_197)-- Content-Type: Message/External-Body; access-type=anon-ftp; name="jcode.pl-2.11"; directory="/pub/IIJ/dist/utashiro/perl/"; site="ftp.iij.ad.jp" Content-Transfer-Encoding: 7bit Content-Type: Text/Plain Content-ID: <14438.20294.334@bbright.iij.ad.jp> ----Next_Part(Mon_Dec_27_02:41:53_1999_197)---- ============================================================================== 2.10 (1999/01/10 13:43:14) ============================================================================== Return-Path: utashiro@iij.ad.jp Received: from ns.iij.ad.jp (root@ns.iij.ad.jp [192.168.2.8]) by fs.iij.ad.jp (8.8.5/3.5Wpl7) with ESMTP id XAA05576 for ; Sun, 10 Jan 1999 23:13:31 +0900 (JST) Received: from mgi.iij.ad.jp (root@mgi.iij.ad.jp [192.168.2.5]) by ns.iij.ad.jp (8.8.5/3.5Wpl7) with ESMTP id XAA14131 for ; Sun, 10 Jan 1999 23:13:31 +0900 (JST) Received: from bbright.iij.ad.jp (h163.n127.iijnet.or.jp [202.232.177.163]) by mgi.iij.ad.jp (8.8.8/MGI1.0) with ESMTP id XAA17440 for ; Sun, 10 Jan 1999 23:13:30 +0900 (JST) Received: from localhost (localhost.bbright.iij.ad.jp [127.0.0.1]) by bbright.iij.ad.jp (8.8.5/8.8.5) with ESMTP id XAA14486 for ; Sun, 10 Jan 1999 23:13:23 +0900 (JST) X-Newsgroups: fj.comp.lang.perl,fj.sources In-Reply-To: <19981226011652M.utashiro@iij.ad.jp> References: <19981226011652M.utashiro@iij.ad.jp> Mime-Version: 1.0 Message-Id: <19990110231321Q.utashiro@iij.ad.jp> X-Dispatcher: imput version 981124(IM104) Lines: 29 Content-Type: Multipart/Mixed; boundary="--Next_Part(Sun_Jan_10_23:10:31_1999_266)--" Content-Transfer-Encoding: 7bit Subject: jcode.pl-2.10 released From: Kazumasa Utashiro Cc: utashiro@iij.ad.jp Date: 10 Jan 1999 23:13:21 +0900 X-Mailer: Mew version 1.94b2 on Emacs 19.28 / Mule 2.3 (SUETSUMUHANA) Followup-To: fj.comp.lang.perl ----Next_Part(Sun_Jan_10_23:10:31_1999_266)-- Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit $B:rG/Kv$K%j%j!<%9$7$?(B jcode.pl-2.9 $B$K%P%0$,$"$k$3$H$rH/8+$7$^$7$?!#%3!<(B $B%IJQ49$K$O;Y>c$,$"$j$^$;$s$,!"(B&jcode'tr $B$,$&$^$/F0:n$7$^$;$s!#(B $B=$@5$7$?%P!<%8%g%s$r(B 2.10 $B$H$7$FCV$-$^$7$?$G!"$3$A$i$r$4MxMQ$/$@$5$$!#(B &jcode'tr $B4X?t$r;H$C$F$$$J$1$l$P2?$bLdBj$O$"$j$^$;$s$,!":FG[IU$7$F$$$k(B $B$7$F$$$kJ}$O!"I,$:(B 2.10 $B$KF~$l49$($F$/$@$5$$!#(B $B$3$N7o$G$4LBOG$r$*$+$1$7$?J}$,$$$^$7$?$i!"?=$7Lu$"$j$^$;$s$G$7$?!#H?>J(B $B$7$F(B &jcode'tr $B4X?t$N%F%9%H4D6-$bMQ0U$7$?$N$G!":#8e$OBg>fIW$@$H;W$$$^$9!#(B --utashiro ----Next_Part(Sun_Jan_10_23:10:31_1999_266)-- Content-Type: Message/External-Body; access-type="anon-ftp"; name="jcode.pl-2.10"; directory="/pub/IIJ/dist/utashiro/perl/"; site="ftp.iij.ad.jp" Content-Transfer-Encoding: 7bit Content-Type: Text/Plain Content-ID: <13976.45204.266@bbright.iij.ad.jp> ----Next_Part(Sun_Jan_10_23:10:31_1999_266)---- ============================================================================== 2.9 (1998/12/25 15:48:04) ============================================================================== From: Kazumasa Utashiro Newsgroups: fj.comp.lang.perl,fj.sources Subject: jcode.pl-2.9 released Followup-To: fj.comp.lang.perl Date: 26 Dec 1998 01:16:52 +0900 Organization: Internet Initiative Japan Inc., Tokyo, JAPAN Lines: 33 Message-ID: <19981226011652M.utashiro@iij.ad.jp> NNTP-Posting-Host: h163.n127.iijnet.or.jp Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Sat_Dec_26_01:13:41_1998_689)--" Content-Transfer-Encoding: 7bit X-Mailer: Mew version 1.94b2 on Emacs 19.28 / Mule 2.3 (SUETSUMUHANA) X-Dispatcher: imput version 981124(IM104) ----Next_Part(Sat_Dec_26_01:13:41_1998_689)-- Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit $B%/%j%9%^%9$K$O$A$g$C$HCY$l$^$7$?$,!"(BPerl $B$K$h$kF|K\8lJ8;z%3!<%IJQ49%i(B $B%$%V%i%j(B jcode.pl-2.9 $B$r%j%j!<%9$7$^$9!#(B $B:#2s$O5!G=E*$JJQ99$O$^$C$?$/L5$7$G!"JQ$o$C$?$N$O(B - $`, $&, $' $B$NMxMQ$rGS=|(B $B$H$$$&E@$@$1$G$9!#%W%m%0%i%`$K$h$C$F$O=hM}B.EY$,BgI}$K2~A1$7$^$9!#(B $B:#$^$GCN$C$F$O$$$?$b$N$N!"$"$^$j5$$K$7$F$$$J$+$C$?$N$G$9$,!"$3$l$,8zN((B $B$KBg$-$/1F6A$rM?$($k%W%m%0%i%`$r:n@.$9$kI,MW$,@8$8$?$3$H$G(B jcode.pl $B$b(B $B9g$o$;$FJQ99$7$^$7$?!#(B --utashiro ----Next_Part(Sat_Dec_26_01:13:41_1998_689)-- Content-Type: Message/External-Body; access-type="anon-ftp"; name="jcode.pl-2.9"; directory="/pub/IIJ/dist/utashiro/perl/"; site="ftp.iij.ad.jp" Content-Transfer-Encoding: 7bit Content-Description: jcode.pl-2.9 Content-Type: Text/Plain Content-ID: <13955.46522.299@bbright.iij.ad.jp> ----Next_Part(Sat_Dec_26_01:13:41_1998_689)---- ============================================================================== 2.8 (1998/09/23 17:22:55) ============================================================================== From: Kazumasa Utashiro Newsgroups: fj.comp.lang.perl Subject: jcode.pl-2.8 released Date: 24 Sep 1998 02:52:28 +0900 Organization: Internet Initiative Japan Inc., Tokyo, JAPAN Lines: 39 Message-ID: <19980924025228D.utashiro@iij.ad.jp> References: <19980906013839V.utashiro@iij.ad.jp> NNTP-Posting-Host: h163.n127.iijnet.or.jp Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Thu_Sep_24_02:45:28_1998_911)--" Content-Transfer-Encoding: 7bit X-Mailer: Mew version 1.93 on Emacs 19.28 / Mule 2.3 (SUETSUMUHANA) X-Dispatcher: imput version 980923(IM101) ----Next_Part(Thu_Sep_24_02:45:28_1998_911)-- Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Perl $B$K$h$kF|K\8lJ8;z%3!<%IJQ49%i%$%V%i%j(B jcode.pl-2.8 $B$r%j%j!<%9$7$^(B $B$7$?!#(B ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/jcode.pl-2.8 2.6 $B$+$i$NJQ99E@$O!"0J2<$NDL$j$G$9!#(B - JIS X 0212 ($BJd=u4A;z(B) $B$N%5%]!<%H(B (SJIS $B$KJQ49$9$k>l9g$K$O!X".!Y$KJQ49$5$l$^$9(B) - Perl5 $B$G;HMQ$9$k>l9g$N%$%s%?%U%'!<%9$r5-=R(B - $B ----Next_Part(Thu_Sep_24_02:45:28_1998_911)---- ============================================================================== 2.6 (1997/12/24 17:01:11) ============================================================================== Newsgroups: fj.lang.perl Subject: jcode.pl-2.6 Cc: utashiro@iij.ad.jp Mime-Version: 1.0 Organization: Internet Initiative Japan Inc. Cc: utashiro@iij.ad.jp Content-Type: Multipart/Mixed; boundary="--Next_Part(Thu_Dec_25_02:12:24_1997_651)--" Content-Transfer-Encoding: 7bit X-Mailer: Mew version 1.93b6 on Emacs 19.28 / Mule 2.3 (SUETSUMUHANA) Message-Id: <19971225021947T.utashiro@iij.ad.jp> Date: 25 Dec 1997 02:19:47 +0900 From: Kazumasa Utashiro X-Dispatcher: imput version 971106 Lines: 30 ----Next_Part(Thu_Dec_25_02:12:24_1997_651)-- Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit jcode.pl-2.6 $B$r%j%j!<%9$7$^$7$?!#(B ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/jcode.pl-2.6 2.3 $B$+$i$NJQ99E@$O!"0J2<$NDL$j!#(B - &jcode'tr $B$NCf$G(B JIS $B%3!<%I$NG'<1J}K!$r$A$g$C$H$@$1JQ99(B - JIS X 0208-1990 $B$N%7!<%/%(%s%9$rG'<1$9$k$h$&$KJQ99(B - &jcode'getcode $B$N%P%0$r=$@5$7$F!"@bL@$rDI2C(B --utashiro ----Next_Part(Thu_Dec_25_02:12:24_1997_651)-- Content-Type: Message/External-Body; access-type="anon-ftp"; name="jcode.pl-2.6"; directory="/pub/IIJ/dist/utashiro/perl/"; site="ftp.iij.ad.jp" Content-Transfer-Encoding: 7bit Content-Description: jcode.pl-2.6 Content-Type: Text/Plain Message-ID: 13473.16799.349@bbright.iij.ad.jp ----Next_Part(Thu_Dec_25_02:12:24_1997_651)---- ============================================================================== 2.3 (1997/02/23 14:12:26) ============================================================================== Newsgroups: fj.lang.perl,fj.sources Cc: utashiro@iij.ad.jp Subject: jcode.pl-2.3 X-Mailer: Mew version 1.54 on Emacs 19.28.1, Mule 2.2 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Tue_Feb_25_23:49:30_1997)--" Content-Transfer-Encoding: 7bit Organization: Internet Initiative Japan Inc. Message-Id: <19970225234940Y.utashiro@iij.ad.jp> Date: 25 Feb 1997 23:49:40 +0900 From: Kazumasa Utashiro X-Dispatcher: impost version 0.93+ (Nov. 23, 1996) Lines: 34 ----Next_Part(Tue_Feb_25_23:49:30_1997)-- Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit $BF|K\8l%3!<%IJQ49(B Perl $B%i%$%V%i%j(B jcode.pl $B$N(B &jcode'tr $B4X?t$K%-%c%C%7%e(B $B$N5!G=$rF~$l$F!"F1$8JQ49$rO"B3$7$F9T$&>l9g$N8zN($r2~A1$7$^$7$?!#$=$NB>!"(B $Be$N%^%$%J!<$JJQ99$,$5$l$F$$$^$9!#(B JIS $B$+(B EUC $B$J$i!"(B &jcode'tr(*_, '$B$"(B-$B$s(B', '$B%"(B-$B%s(B'); &jcode'tr(*_, '$B#0(B-$B#9#A(B-$B#Z#a(B-$B#z(B', '0-9A-Za-z'); $B$N$h$&$J;H$$J}$b2DG=$G$9(B (2.0 $B$+$i(B)$B!#(B ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/jcode.pl-2.3 $B$+$iF~ Message-Id: <199610021727.CAA19339@cpu1.iij.ad.jp> Newsgroups: fj.lang.perl,fj.sources,fj.kanji Subject: jcode.pl-2.0 and pkf-2.0 release announcement References: <19960815164047I/utashiro@iij.ad.jp> <19960820041332P/utashiro@iij.ad.jp> <19960910141123W/utashiro@iij.ad.jp> Followup-To: fj.lang.perl Organization: Internet Initiative Japan Inc. Apparently-To: jcode.pl-2.0 $B$*$h$S(B pkf-2.0 $B$r@5<0%j%j!<%9$7$^$7$?!#%Y!<%?$NM-8z4|8B$r(B $BL>(B ($B$$$o$f$kH>3Q2>L>(B) $B$,4^$^$l$k%G!<%?$K$D$$$F$bJQ(B $B49$G$-$k$h$&$K$J$C$?!#(B + JIS X 0201 $B2>L>$H(B JIS X 0208 $B2>L>(B ($B$$$o$f$kA43Q2>L>(B) $B$N4V$NAj8_(B $BJQ49$r%5%]!<%H$7$?!#(B(&jcode'h2z_xxx, &jcode'z2h_xxx $B$HJQ494X?t$K(B $BBP$9$k%*%W%7%g%s(B) + Perl $B$N(B tr $B4X?t$r%(%_%e%l!<%H$9$k(B &jcode'tr $B$G!"IT40A4$J$,$i(B2$B%P(B $B%$%H%3!<%I$NHO0O;XDj(B ('$B$"(B-$B$s(B' $B$N$h$&$J$b$N(B) $B$r%5%]!<%H$7$?!#(B + $B%9%+%i!l9g$K$OM-8z$G$"$k(B) $B$?$@$7!"(B - JIS X 0201 $B2>L>$,4^$^$l$k>l9g$NF|K\8l%3!<%I$N<+F0G'<1$OJ]>Z$7$^(B $B$;$s!#(B - JIS $B$N(B SO, SI $B$K$h$k(B X 0201 $B2>L>%3!<%I$K$D$$$F$OBP1~$7$F$$$^$;$s!#(B $Bl9g$O!"$=$NBP1~$,I,MW$G$7$g$&!#%i%$%V%i%j$r;H$C$F$$$k%9%/%j%W%H$+(B $B$i!"%$%s%?%U%'!<%9$H$7$FDj5A$5$l$F$$$J$$JQ?t$r;HMQ$9$k$N$O!"$"$^$j$*4+(B $B$a$7$^$;$s!#(B $B""""(B pkf-2.0 $B$O!"(Bjcode.pl-2.0 $B$N5!G=$r;H$&$h$&$KJQ99$7$?!"F|K\8l%3!<%IJQ49(B $B%3%^%s%I$G$9!#85!9$O(B jcode.pl $B$N%F%9%HMQ$K:n$i$l$?%3%^%s%I$G(B nkf $B$H;w(B $B$?5!G=$r;}$C$F$$$^$9$,!"FH<+$N5!G=$b>/$7$"$j$^$9!#(B pkf-1.10 $B$+$i$NJQ99E@$O!"0J2<$NDL$j$G$9!#(B + -Z $B%*%W%7%g%s$G(B JIS X 0201 $B2>L>$+$i(B JIS X 0208 $B2>L>$X$NJQ49(B + -H $B%*%W%7%g%s$G(B JIS X 0208 $B2>L>$+$i(B JIS X 0201 $B2>L>$X$NJQ49(B + -n $B%*%W%7%g%s$G%3!<%IJQ49$r9T$o$J$$$3$H$r;XDj(B $B""""(B jcode.pl $B$b$=$l$rMxMQ$9$k(B pkf $B$b!"(BC $B8@8l$G$+$+$l$?%W%m%0%i%`$KHf$Y$k$H(B $BHs>o$K!XCY$$!Y$H$$$&FCD'$r;}$C$F$$$^$9!#$G$9$+$i!"BgNL$N%G!<%?$r8zN(NI(B $B$/JQ49$9$k$h$&$JMQES$K$O8~$$$F$$$J$$$N$G!"Cm0U$7$F$/$@$5$$!#(B $B""""(B $B%3%a%s%H$K$b=q$$$F$"$j$^$9$,!":FG[I[$O>&MQ!"Hs>&MQ$r4^$a$F40A4$K<+M3$G(B $B$9!#:FG[I[$K:]$7$F!":nl9g$O!"$=$l$,L@$i$+$J7A$G$NG[I[$r9T$C$F2<(B $B$5$$(B (Perl $B$N(B ARTISTIC LICENCE $B$N5$;}$A$G$9(B)$B!#$b$A$m$s!"M-MQ$J5!G=$G$"(B $B$l$P%*%j%8%J%k$KAH$_F~$l$k$3$H$b2DG=$G$9!#(B $B""""(B $B%P%0%l%]!<%H$=$NB>$K$D$$$F$O(B fj.lang.perl $B$KEj9F$9$k$+(B ($BB>$N%0%k!<%W$O(B $BLGB?$KFI$_$^$;$s(B)$B!"(Butashiro@iij.ad.jp $B$K%a!<%k$G$*CN$i$;$/$@$5$$!#(B --utashiro