Encode::HanDetect - Cross-encoding, cross-variant Chinese decoder
This document describes version 0.01 of Encode::HanDetect, released January 31, 2003.
use Encode; use Encode::HanDetect; use Encode::Guess qw(utf8 latin1); # fallbacks my $utf8 = decode("HanDetect", $data); my $data = encode("HanDetect", $utf8); # this won't work use Encode::HanDetect 'traditional' # auto-convert to traditional
Encode::HanDetect is a thin wrapper around Lingua::ZH::HanDetect, providing the ability to treat any incoming Chinese data equally, regardless of its encoding.
If a string beginning with either t or s is specified in the use line, all incoming data streams will be converted to that variant using Encode::HanConvert.
t
s
use
When Lingua::ZH::HanDetect cannot detect the encoding (most likely because it contains no Chinese characters), it simply falls back to the Guess encoding provided by Encode::Guess.
Guess
If you use less as pager, setting your LESSOPEN environment to "perl -0777 -MEncode::HanDetect=trad -MEncode::Guess=utf8,iso8859-15 /usr/local/bin/piconv -f HanDetect %s > /tmp/less; echo /tmp/less" will automatically convert all Chinese files Traditional Chinese (while leaving non-Chinese text encoded in utf8 or <iso8859-15> intact), and displayed in the encoding specified by my current locale.
less
LESSOPEN
"perl -0777 -MEncode::HanDetect=trad -MEncode::Guess=utf8,iso8859-15 /usr/local/bin/piconv -f HanDetect %s > /tmp/less; echo /tmp/less"
utf8
Simplified Chinese users can simply replace the =trad above to =simp, or omit it if your terminal can display both variants.
=trad
=simp
Encode, Encode::Guess
Encode::HanConvert, Lingua::ZH::HanDetect
Autrijus Tang <autrijus@autrijus.org>
Copyright 2003 by Autrijus Tang <autrijus@autrijus.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install Encode::HanDetect, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Encode::HanDetect
CPAN shell
perl -MCPAN -e shell install Encode::HanDetect
For more information on module installation, please visit the detailed CPAN module installation guide.