Here are the codes:
big5_2_utf8.pl
Code: Select all
#!/usr/local/bin/perl
################################################################################
#
# Author : Chang-An Hsiao
# Created On : 01/04/2017
# Last Modified By : Chang-An Hsiao
# Last Modified On :
# Update Count :
# Status : Working
#
# HISTORY
#
# 01/04/2017 Chang-An Hsiao
#
# - Create the new script to convert from BIG-5 encoding to UTF-8
#
################################################################################
use Encode;
$ARGC = "".@ARGV;
if ($ARGC < 2) {
print "Usage: big5_2_utf8 <BIG-5 file> <UTF-8 file>\n";
exit -1;
}
$big5=$ARGV[0];
$utf8=$ARGV[1];
open(BIG5, "$big5");
open(UTF8, ">$utf8");
while (<BIG5>) {
$text=encode('utf8', decode('big5', $_));
print UTF8 $text;
}
close UTF8;
close BIG5;
Code: Select all
#!/usr/local/bin/perl
################################################################################
#
# Author : Chang-An Hsiao
# Created On : 01/04/2017
# Last Modified By : Chang-An Hsiao
# Last Modified On :
# Update Count :
# Status : Working
#
# HISTORY
#
# 01/04/2017 Chang-An Hsiao
#
# - Create the new script to convert from UTF-8 encoding to BIG-5
#
################################################################################
use Encode;
$ARGC = "".@ARGV;
if ($ARGC < 2) {
print "Usage: utf8_2_big5 <UTF-8 file> <BIG-5 file>\n";
exit -1;
}
$utf8=$ARGV[0];
$big5=$ARGV[1];
open(UTF8, "$utf8");
open(BIG5, ">$big5");
while (<UTF8>) {
$text=encode('big5', decode('utf8', $_));
print BIG5 $text;
}
close BIG5;
close UTF8;