| CPAN Ratings (Gamma) Encode reviews | |
| Home | Search | About | Login |
RSS | Module Info | Add a review of Encode
1 out of 3 found this review helpful:
This is a review of "Encode::Guess", not "Encode" (blame cpanratings for this).
Encode::Guess is a Perl module which guesses the kind of character encoding of some data. It's mostly intended for distinguishing between the dozens of confusing encoding systems used in Japanese and Chinese and other such languages, and doesn't make many promises about being able to guess the encodings of European character sets.
My main interest is in Japanese encodings, and I used Encode::Guess
successfully to decode some files written in either CP932 (Shift JIS) or UTF-8.
Although the module worked, and did its job well, I still have to say that this implementation is counterintuitive. First of all the documentation is very bizarre. The very first thing it tells you, the example in the "Synopsis" section of the documentation, to use Encode::decode ("Guess",...) is horrible and you will be miserable if you try to use this. I guess most people will do the same thing as me and start with the example in the synopsis before they read the whole of the documentation. It was only after struggling with the decode ("Guess",...) method that I came across another way to access this module's functions, buried down in the middle of the documentation. This is to make a $decoder object using Encode::Guess->guess.
The interface is idiosyncratic, but this worked very much more smoothly than using decode ("Guess",...). For example, decode ("Guess",...) just dies if it encounters an error, and it seems to be quite buggy. The object method doesn't die on any kind of error, but just returns a string (instead of a ref) if it fails. [So you have to check whether you got a string or a ref back to find out whether it failed, which is odd, but never mind.] Using the decoder turned out to accomplish what I had wanted to do very well.
As a suggestion for improvement, one thing I think a lot of people would find useful is a way to ask the module to guess the encoding of a file without my having to read the file, catch errors, close the file again, and then decode the contents. A simple routine which takes a file name as an argument and returns a string to send to "encoding", as in
my $XYZ = tell_me_the_file_encoding_of($weirdfile);
die "Unknown encoding" if !$XYZ;
open my $input, "<:encoding($XYZ)", $weirdfile or die $!;
would be handy.
In general this is a highly useful module but I can't give five stars since the interface and documentation are fairly iffy, and the decode ("Guess" thing even seems quite buggy.
BKB - 2008-08-01 21:22:48
Was this review helpful to you?
Yes
No
I use this module to convert documents from utf8 to a user defined encoding.
Installation: I could not find it on YAST, so I used 'make' and so on. It is clearly a big module, because it generated a lot of files, but it worked flawlessly.
Usage: simple and straightforward. With 3 lines of code I had all I needed:
use Encode;
my @list = Encode->encodings(':all');
Encode::from_to($string, 'utf8', $selected_encoding);
The @list contains all available encodings which I feed into a selection list. The from_to function does the transformation. I checked it with German, Czech, Cyrillic and Hebrew characters and it all worked fine.
Good stuff.
Marianne Mandl - 2007-06-22 00:36:16
Was this review helpful to you?
Yes
No
This module works very well. Though I am deeply mystified by Unicode, charsets, and so on (isn't everyone?), this module comes through for me.
Kai Carver - 2006-11-20 06:18:49
Was this review helpful to you?
Yes
No
|
Perl.org sites
: bugs
| dev
| history
| jobs
| learn
| lists
| use
Site Information and Contacts |
|