| Server IP : 216.92.14.13 / Your IP : 216.73.216.171 Web Server : Apache System : Linux vps4089.pairvps.com 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 User : rmlac2fmr ( 1040637) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/bin/ |
Upload File : |
#!/usr/local/bin/perl
$VERSION = '0.14';
=head1 NAME
g2b.pl - Simplified to Traditional Chinese converter
=head1 SYNOPSIS
B<g2b.pl> [ B<-p> ] [ B<-u> ] [ I<inputfile> ...] > I<outputfile>
=head1 USAGE
% g2b.pl -p < gbk.txt > big5.txt
% g2b.pl -pu < simp.txt > trad.txt
=head1 DESCRIPTION
The B<g2b.pl> utility reads files sequentially, converts them from
Simplified to Traditional Chinese, then writes them to the standard
output. The I<inputfile> arguments are processed in command-line order.
If I<inputfile> is a single dash (C<->) or absent, this program reads
from the standard input.
The C<-p> switch enables rudimentary phrase-oriented substition via a
small built-in lexicon.
The C<-u> switch specifies that both the input and output streams should
be UTF-8 encoded. If not specified, the input stream is assumed to be
in GBK, and the output will be encoded in Big5.
=head1 CAVEATS
In pure-perl implementations (pre-5.8 perl or without a C compiler),
C<-p> and C<-u> cannot be used together.
=cut
use strict;
use warnings;
use Getopt::Std;
sub MAP ();
my %opts;
BEGIN {
getopts('hup', \%opts);
if ($opts{h}) { system("perldoc", $0); exit }
$SIG{__WARN__} = sub {};
}
use constant UTF8 => $opts{u};
use constant DICT => ($opts{p} and (!UTF8 or $] >= 5.008));
use Encode::HanConvert;
my $KEYS = join('|', map quotemeta, sort { length($b) <=> length($a) } keys %{+MAP}) if DICT;
my $MAP = +MAP if DICT;
if (@ARGV) {
for (@ARGV) {
unless(open F, $_) {
warn "Can't open $_: $!";
next;
}
convert(\*F);
close F;
}
} else {
convert(\*STDIN);
}
sub convert {
my ($fh) = @_;
if ($] >= 5.008) {
if (UTF8) {
binmode($fh, ':encoding(simp-trad)'); binmode(STDOUT, ':utf8')
} else {
binmode($fh, ':encoding(gbk-trad)'); binmode(STDOUT, ':encoding(big5)')
}
}
while (<$fh>) {
unless ($] >= 5.008) {
if (UTF8) { Encode::HanConvert::simp_to_trad($_) }
else { Encode::HanConvert::gb_to_big5($_) }
}
if (DICT) { s/($KEYS)/$MAP->{$1}/g }
print;
}
}
use constant MAP => DICT && {
map { UTF8 ? Encode::decode(big5 => $_) : $_ } reverse (
'�A��' => '�H��',
'�A�Ӻ��' => '�H�Ӻ�',
'�E�E���k��' => '�E�E��',
'�K��' => '�K�`',
'�X�C' => '���C',
'���_�I' => '�_�I',
'���H' => '���`',
'����' => '���f',
'����' => '�ե�',
'���ƥ]' => '����]',
'�ɵ��Ҹ�' => '�ɯŦҸ�',
'�ɾ�' => '�ɧ�',
'�̧x' => 'ˮ�x',
'�ӪŤH' => '��ѭ�',
'�ӪŦ�' => '�t�z����A',
'�Ӫű�' => '��ѭ���',
'�ӪŲ�' => '�t�z����',
'��ګ���' => '�ຸ�ڳ��',
'��f�Wï' => '��fï',
'�䴩' => '��',
'���' => '������',
'�麸�ҥ���' => '��հҥ���',
'���ı�' => '����',
'����' => '����',
'���y' => '����',
'�\\���' => '���',
'�]��' => '�c��',
'�v�F�L' => '���j�L',
'�~�Ӫ�' => '�~�h�Ŷ�',
'����' => '�e��',
'����' => '����',
'����@�~' => '�æ�ާ@',
'�����' => '�æ�ݤf',
'����u' => '�æ�u',
'���X��' => '�����',
'����' => '����',
'���' => '�ƾ�',
'��h�y' => '��',
'��' => '����',
'���о�' => '���X',
'����' => '����',
'�@��' => '�@��',
'�B��' => '�ΦB',
'�C�L' => '���L',
'�L��' => '���L��',
'�V����' => '�V�ۥ���',
'�]��' => '�]�l',
'�j��' => '�`��',
'�^��' => '�T��',
'�h�����[' => '�h�̥��[',
'�r��' => '�r�Ŧ�',
'�r��' => '�e��',
'�s��' => '�s�L',
'���Ⱦ�' => '���ھ�',
'�жq��' => '���q��',
'�����' => '�J��X���',
'�褸' => '����',
'��}' => '�a�}',
'��C' => '���C',
'����' => '����',
'���A��' => '�A�Ⱦ�',
'�@�~�t��' => '�ާ@�t��',
'�B���u' => '�B����',
'�C���y��' => '�C�Ży��',
'�Y��' => '���',
'�l����' => '�l�ۥ���',
'�����Դ�' => '�x���Դ�',
'�ǦC��' => '���ݤf',
'�˰�' => '���',
'�F�Ԫo' => '��Ԫo',
'�F�Q�a���ԧB' => '�F�S���ԧB',
'�H�A' => '�I�A',
'���M' => '�^�M',
'�����n' => '����n',
'���g' => '�g�O�@',
'�Ӻֽu' => '�ӽƽu',
'��L' => '�䥦',
'��w' => '��ij',
'���b' => '�u�ʱ�',
'�P��' => '�~��',
'�}����' => '�}�ۥ���',
'�ݸO' => 'ݭ�O',
'�`�}' => '�}�`',
'�`��' => '��`',
'����' => '�§�',
'����' => '��H',
'����' => '���',
'���ѥ��l' => '���Ѥ��l',
'����' => 'ֺ��',
'������' => 'ֺ��',
'���q����' => 'ֺ�����',
'�ť��' => '�Ů��',
'��N��' => '�C�N��',
'���w' => '���|',
'���i����' => '���i���S��',
'�������F' => '���q�ǪL',
'�c�M' => '�K�M',
'�n��' => '�f��',
'�˳H�^' => '�˳H��',
'����' => '���w',
'�A��' => '�A��',
'�H���Ѥ�' => '���Ѥ�',
'�M�g' => '�M��',
'�ȥ���' => '�ȱۥ���',
'�ۮe' => '�ݮe',
'�C�ϸ`' => '�t�ϸ`',
'�I����' => '�I�ۥ���',
'�^�o' => '�^�T',
'�p�ɾ�' => '�w�ɾ�',
'�p�{��' => '�X����',
'�p��' => '�p�⾹',
'�}���i' => '�}����',
'����' => '�^��',
'����' => '�\\��',
'�˷�' => '�˾`',
'�Ծ���' => '�Ծ���',
'�M�˳n��' => '�n��]',
'�y��' => '����',
'�z����' => '�z�ۥ���',
'���}' => 'ݵ�}',
'����' => 'ݳ��',
'���b' => 'ѽ�b',
'����' => '���@',
'�B��L' => '��L',
'�Q�C' => '�Q�',
'�Q�H�H' => '�Q�I�I',
'�}���r' => '�h���r',
'���D' => '���y',
'�����Q��' => '������',
'��ż' => '�Qż',
'�K' => '�v�K',
'�㰩' => '�m��',
'���`�p' => '���`�p',
'���' => '��g',
'�O����' => '���s',
'�s�f��' => '�s�t��',
'�}�C' => '�Ʋ�',
'����' => '���',
'�Ƶ{��' => '�l�{��',
'��ɦW' => '�X�i�W',
'�հն�' => '�ԩԶ�',
'��Ū' => '�uŪ',
'���|' => '���',
'�M��' => '����',
'�`��' => '�ҵ{',
'�d�D�f��' => '�d�I�f�J',
'���|' => '�ֱ��覡',
'���y��' => '���y��',
'�Ұ�' => '�E��',
'����w�z' => '�Īѩw�z',
'���d��' => '���[��',
'�˻�' => '���',
'�����S' => '����S',
'�J��' => '��',
'�n��' => '����',
'�q�T��' => '�q�Tï',
'�q�D' => '�H�D',
'�s�u' => '�p��',
'�t��' => '��\\',
'���Z' => '���`',
'���H�H' => '���I�I',
'���K�K' => '�����',
'�¤l' => '��l',
'�¶�Ѷ�' => '���ĽѶ�',
'�·��' => '���F',
'�ټM' => '�~�M',
'����' => 'ݴ��',
'����' => '����',
'����' => '����',
'����' => '��',
'���z' => '����',
'���' => '����',
'�L�k���a' => '�^�k���a',
'�f�X' => '���U',
'�n�X' => '�`�P',
'�w��' => '�w��',
'�{��' => '�{��',
'�{�DZ���' => '�L�{����',
'������' => '������',
'����' => '����',
'����' => '�o��',
'����' => '����',
'��y' => '�S�y',
'�Ҭr' => '�Ϭr',
'����' => '���f',
'�W�s��' => '�W���챵',
'�l���ϸ�' => '�l�F�s�X',
'�¨H�H' => '�¨I�I',
'�ü�' => '�H����',
'�y��' => '�`�u',
'�콦' => '���',
'���J�Բ����{' => '�X�J�Բ����{',
'���|' => '���e�|',
'�P����' => '�P�ۥ���',
'�s�u���L' => '�s�u������',
'�t�H�H' => '�t�I�I',
'����' => '�B��',
'�ƹ�' => '����',
'�q�j�Q' => '�N�j�Q',
'�t�a����' => '�t�a�ȭ�',
'�ѪR��' => '����v',
'�ѽX' => 'Ķ�X',
'�պ��' => '�q�l���',
'��T' => '�H��',
'���J' => '�[��',
'�B�⤸' => '�ާ@��',
'�B�⦡' => '��F��',
'�O�~' => '�Ʀ~',
'�P�@' => '�Q�@',
'�d�I' => '���I',
'�h�D' => '���',
'�p�g�L��' => '�E�����L��',
'�p��' => '����',
'�q����' => '�����',
'�q�ǵ��T' => '�Ϥ�q��',
'�q��' => '�p��',
'�q���{��' => '�p���{��',
'�q��' => '�q����',
'��ù' => '���o',
'�ϥ�' => '�ϼ�',
'�G�F' => '�G�H',
'�P�X' => '��X',
'�j�f' => '��f',
'�t��k' => '��k',
'���E' => '����',
'����' => '�詥',
'�Ϥ�' => '�ϽL',
'�ϭy' => '�ϹD',
'�ϰ�' => '����',
'�Ϻ�' => '�ϽL',
'�Ϻо�' => '�ϽL�X�ʾ�',
'�Ϻ��' => '�ϽL���',
'�ү��X' => '������',
'�ְ��L' => '�ֺ����L',
'���' => '���_',
'���' => '��',
'éé�g�g' => '�X�X����',
'é�g' => '�X��',
'�`��' => '�j��',
'���h' => '�b��',
'���|����' => '���|���',
'����' => '���{',
'��' => '����',
'��f' => '�\\�f',
'���۰�' => '�\\�\\�۰�',
'�x��' => '����',
'�ƾھ�' => '�ը�ѽվ�',
'�Ȧs��' => '�w�s��',
'��ñ' => '����',
'�Ҳ�' => '�Ҷ�',
'���' => '��u',
'����p��' => '��u�p�⾹',
'�Y��' => '�L��',
'�d��' => '�ҪO',
'�k���k��' => '�J���J��',
'�k��' => '�J��',
'�u�W�@�~' => '�p���ާ@',
'���' => '���',
'���R' => '��ľ�R',
'�A�~' => '�A��',
'�B�n' => '�̽�',
'�K����' => '�K��',
'���H�H' => '���I�I',
'����' => '��',
'��p' => '�A�p',
'�n��q��' => '�����q��',
'�ù�' => '�̹�',
'�Ը�' => '�t��',
'�հҦa' => '�հҩ�',
'�հҲ�' => '�հҩ�',
'���v' => '����',
'�J��' => '�箫',
'�z��' => '�z�B',
'�V��' => '��',
'�ͥ���' => '�ͱۥ���',
'��' => '�ҿ�',
'�鿤' => '���',
'���N�O' => '�B�N�O',
'�n��' => '�H��',
'²��' => '�t�ܤ�Z',
'�Ǿ�' => '�ɾ�',
'�Ȥ�' => '��',
'����I' => '����I',
'��T' => '���n',
'�]�]' => '�V�V',
'ù���L�d' => 'ù�����d',
'ù��ù��' => '�o���o��',
'ù�w�q' => 'ù�o�q',
'ùù����' => '�o�o����',
'ùù�۶�' => '�o�o�۶�',
'�ѧO�r' => '���Ѳ�',
'�߽�' => '�k��',
'���' => '����',
'���r' => '���',
'���' => '���',
'�T��' => '����',
'��a��' => '�K�⦡',
'���' => '�r�q',
'�I�ܹ���' => '�T�ܹ���',
'�J�g' => '�E��',
'�v��' => '�O�P',
'�d��' => '�d���\\��',
'�B��' => '����',
'�e�ӧg' => 'ڮ�ӧg',
'�Ʀ�' => '����',
'��Y' => '�A�Y',
'带�' => '�¦�',
'��' => '����',
'�P' => '�J��',
'���' => '�o��',
'₩X' => '���X',
'�^��' => '�^�`',
'�줸��' => '�r�`',
'�쵲' => '�챵',
'�K�X' => '�f�O',
'�u' => '��',
'�v' => '��',
'�y' => '��',
'�z' => '��',
'�g��' => '�٬�',
'�g�|' => '�ٹ|',
'�g��' => '�ٵ�',
'�i�e' => '�x�e',
'�i�O' => '�x�O',
'�i�W' => '�x�W',
'�O�W' => '�x�W',
'�O�_' => '�x�_',
'�O�n' => '�x�n',
'�䭷' => '�x��',
'�ѯ�' => '����',
'�ѥ]' => '���]',
'�ѱ�' => '����',
'����' => '����',
'����' => '����',
'����' => '���Z',
'����' => '���Z',
) }
__END__
=head1 SEE ALSO
L<b2g.pl>, L<Encode::HanConvert>
=head1 AUTHORS
Currently maintained by Kuang-che Wu E<lt>kcwu@csie.orgE<gt>. Orignal author:
Audrey Tang E<lt>cpan@audreyt.orgE<gt>
=head1 COPYRIGHT
Copyright 2002-2009 by Audrey Tang E<lt>cpan@audreyt.orgE<gt>.
Copyright 2006 by Kuang-che Wu E<lt>kcwu@csie.orgE<gt>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See L<http://www.perl.com/perl/misc/Artistic.html>
=cut