#! /usr/local/bin/perl
# $Id: eucconv.pl,v 1.3 2011-01-28 12:52:25+09 shige Exp $
# euc2utf8.pl => eucconv.pl
# Kanji translator from EUC-JP to {UTF-8/SJIS} for styles/japanese.perl
# or others.
# 1-8)
#
use Encode;

binmode STDIN,":encoding(euc-jp)";

if ( $#ARGV >= 0 && $ARGV[0] =~ /utf/i ) {
    binmode STDOUT,":utf8";
    $tocode = "UTF-8";
} elsif ( $#ARGV >= 0 && $ARGV[0] =~ /sjis/i ) {
    binmode STDOUT,":encoding(shiftjis)";
    $tocode = "Shift_JIS";
} elsif ( $#ARGV >= 0 && $ARGV[0] =~ /^jis/i ) {
    binmode STDOUT,":encoding(iso-2022-jp)";
    $tocode = "ISO-2022-JP";
} else {
    binmode STDOUT,":encoding(euc-jp)";
    $tocode = "EUC-JP";
}

while ( <STDIN> ) {
    s/\@CHARSET\@/$tocode/g;
    print;
} 
