Parag Kalra:
Hmmm - http://search.cpan.org/~dankogai/Encode-2.39/lib/Encode/Guess.pm

It says right at the bottom that below method won't work to guess the encoding. :(


Encode::Guess maybe work, but not so exactly.
Because some Code Bits of an encoding are overlapped (for example,gb2312 and gbk),so you can't get the encoding style of a small string just by guess. But for large text,it maybe work rightly.

Here is another guess way (not by me) you may reference to:

use Encode;
use LWP::Simple qw(get);
use strict;

my $str = get "http://www.sina.com.cn";;

eval {my $str2 = $str; Encode::decode("gbk", $str2, 1)};
print "not gbk: $...@\n" if $@;

eval {my $str2 = $str; Encode::decode("utf8", $str2, 1)};
print "not utf8: $...@\n" if $@;

eval {my $str2 = $str; Encode::decode("big5", $str2, 1)};
print "not big5: $...@\n" if $@;


HTH.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to