Click here to get back home

Encode::Guess load ISO-8859-1

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Encode::Guess load ISO-8859-1 =?ISO-8859-1?Q?Une_b=E9vue?= 03-27-2006
Posted by =?ISO-8859-1?Q?Une_b=E9vue?= on March 27, 2006, 10:09 am
Please log in for more thread options


new to Perl, i'd like making use of Encode::Guess, however i get an
error message :

Can't locate object method "name" via package "iso-8859-1 or utf8"
(perhaps you forgot to load "iso-8859-1 or utf8"?) at
/Users/yvon/work/Perl/encoding-check/check_files.pl line 26.
iso-8859-1
iso-8859-1


line 26 being :
return $decoder->name;

i don't understand this error message because perl is able to print out
two times $decoder->name giving "iso-8859-1"

i suppose i have to load another module, but which one ?

the whole script being :
-----------------------------------------------------------
#!/usr/bin/perl

use Encode::Guess;
use base qw(Encode::Encoding);

sub guessEncoding
{
my ($fn) = @_;
my $string;
{
local $/;
open F, $fn or die "can't open $file: $!";
$string = <F>;
close F or die "cannot close $file: $!";
}
Encode::Guess->add_suspects('latin1');
my $decoder = Encode::Guess->guess($string);
return $decoder->name;
}

print guessEncoding("apple-mac-roman--ISO-8859-1.html");
print "\n";
print guessEncoding("comparaison-encodages--ISO-8859-1.html");
print "\n";
print guessEncoding("cp1252--UTF-8.htm");
print "\n";
print guessEncoding("Frap--CP-1252.html");
print "\n";
-----------------------------------------------------------

--
une bévue

Posted by Ruey-Cheng Chen on April 8, 2006, 12:14 pm
Please log in for more thread options


I didn't try your code, but it seems Encode::Guess will croak when it
encounters two or more suspects. According to Encode::Guess manpage,
you can add the following code to figure out what's going on.

my $decoder = Encode::Guess->guess($data);
die $decoder unless ref($decoder);
my $utf8 = $decoder->decode($data);


Similar ThreadsPosted
encode the perl code September 6, 2006, 1:12 am
Building module Encode::Detect on solaris 10 platform February 21, 2008, 9:13 am
Unable to load module March 16, 2006, 12:00 am
UNIVERSAL::can function failing under heavy load August 25, 2005, 11:56 am
Which module should I use in order to load files over the internet? October 5, 2006, 3:38 pm
Looking for a base module that can automatically load sub modules June 27, 2007, 6:16 am
download Modules from CPAN and then load into Perl Question October 15, 2004, 3:07 pm
Cant load ...BerkeleyDB.so for module BerkeleyDB: libdb-4.4.so January 19, 2006, 1:53 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap