#! c:/perl/bin/perl # # Code transfer # 1.001 : 1/3/06 : Added back link. modified convert part. Added English mode. # 1.0 : 8/27/05 : Created # # $Id: trcode.cgi,v 1.4 2006/01/03 04:29:13 Hideki Kanayama Exp $ # Copyright(c) 2005-2006, Hideki Kanayama All rights reserved. use Jcode; use CGI; use strict; use File::Basename; use CGI::Carp qw(fatalsToBrowser); my $script = basename($0); my $version = '1.001'; my $lastupdatedyear = '2006'; my $lang = 0; # 0:Japanese, 1:English my $charset = ('Shift_JIS','ISO-8859-1')[$lang]; my $backlink = "trcode.html"; my $back = "Back"; my $q = new CGI; my $cgierror = $q->cgi_error; &error($cgierror) if ($cgierror); my $mode = $q->param('mode'); my $target = $q->param('target'); if ($mode eq 'convert'){ &convert; } else { &indisp; } sub indisp { &htmlhead; my $convert = ('変換','Convert')[$lang]; my $origfile = ('元ファイル','Original file')[$lang]; print < $back

$origfile
Shift_JIS EUC-JP JIS UTF-8

END &htmltail; } sub convert { print $q->header({-type=>'text/plain',-charset=>"$target"}); $target eq 'Shift_JIS' and $target = 'sjis'; $target eq 'EUC-JP' and $target = 'euc'; $target eq 'ISO-2022-JP' and $target = 'jis'; $target eq 'UTF-8' and $target = 'utf8'; my $upfile = $q->upload('upfile'); if ($upfile){ while (<$upfile>){ print jcode($_)->$target; } close $upfile; } } sub error { my ($msg) = shift; &htmlhead($msg); print "
$msg
\n"; &htmltail; exit; } sub htmlhead { my $title = ('文字コード変換','Character code conversion')[$lang]; print $q->header(-charset=>"$charset"); print "\n"; print "\n"; print "$title\n"; print "\n"; print "\n"; } sub htmltail { my $mysite = ('http://www.hidekik.com/','http://www.hidekik.com/en/')[$lang]; print "
$script Ver. $version
\n"; print "
Copyright(C) 2005-$lastupdatedyear, hidekik.com
\n"; print "\n"; exit; }