| 1 | ##---------------------------------------------------------------------------## | ||
| 2 | ## File: | ||
| 3 | ## $Id: JP.pm,v 1.1 2002/12/18 05:38:43 ehood Exp $ | ||
| 4 | ## Author: | ||
| 5 | ## Earl Hood earl@earlhood.com | ||
| 6 | ##---------------------------------------------------------------------------## | ||
| 7 | ## Copyright (C) 2002 Earl Hood, earl@earlhood.com | ||
| 8 | ## | ||
| 9 | ## This program is free software; you can redistribute it and/or modify | ||
| 10 | ## it under the terms of the GNU General Public License as published by | ||
| 11 | ## the Free Software Foundation; either version 2 of the License, or | ||
| 12 | ## (at your option) any later version. | ||
| 13 | ## | ||
| 14 | ## This program is distributed in the hope that it will be useful, | ||
| 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | ## GNU General Public License for more details. | ||
| 18 | ## | ||
| 19 | ## You should have received a copy of the GNU General Public License | ||
| 20 | ## along with this program; if not, write to the Free Software | ||
| 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
| 22 | ## 02111-1307, USA | ||
| 23 | ##---------------------------------------------------------------------------## | ||
| 24 | |||
| 25 | package MHonArc::Char::JP; | ||
| 26 | |||
| 27 | our $VERSION = '2.6.24'; | ||
| 28 | |||
| 29 | sub jp_2022_to_euc { | ||
| 30 | # implementation of this function plagerized from Encode::JP::JIS7. | ||
| 31 | my $data_in = shift; | ||
| 32 | my $data_r = ref($data_in) ? $data_in : \$data_in; | ||
| 33 | |||
| 34 | my ($esc_0212, $esc_asc, $esc_kana, $chunk); | ||
| 35 | $$data_r =~ s{(?:(\e\$\(D)| # JIS 0212 | ||
| 36 | (?:\e\$\@|\e\$B|\e&\@\e\$B)| # JIS 0208 | ||
| 37 | (\e\([BJ])| # ISO ASC | ||
| 38 | (\e\(I)) # JIS KANA | ||
| 39 | ([^\e]*)} | ||
| 40 | { | ||
| 41 | ($esc_0212, $esc_asc, $esc_kana, $chunk) = | ||
| 42 | ($1, $2, $3, $4); | ||
| 43 | if (!$esc_asc) { | ||
| 44 | $chunk =~ tr/\x21-\x7e/\xa1-\xfe/; | ||
| 45 | if ($esc_kana) { | ||
| 46 | $chunk =~ s/([\xa1-\xdf])/\x8e$1/og; | ||
| 47 | } elsif ($esc_0212) { | ||
| 48 | $chunk =~ s/([\xa1-\xfe][\xa1-\xfe])/\x8f$1/og; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | $chunk; | ||
| 52 | }gex; | ||
| 53 | } | ||
| 54 | |||
| 55 | 1; |