perl-unicode

Encode vs encoding

2004-09-12 00:30:05
Hi to all list users.

Can someone *please* explain me the
difference between (except the scope) encoding and Encode::encode()?
I know encoding affects all the code, but what else does
it do to do the right thing or am I missing something with Encode?

I'm using ActivePerl 5.8.4 build 810 under Windows 2000
and here are the examples:


#!/usr/bin/perl -w
use strict;
my $char = "\xFE";
print ord $char; # prints 254

#!/usr/bin/perl -w
use strict;
use Encode;
my $char = "\xFE";
   $char = encode 'ISO-8859-9', $char;
print ord $char; # prints 63

#!/usr/bin/perl -w
use strict;
use Encode;
my $char = "\xFE";
   $char = encode 'ISO-8859-9', $char, Encode::FB_CROAK();
# dies with: "\x{00fe}" does not map to iso-8859-9
print ord $char;

#!/usr/bin/perl -w
use strict;
use encoding 'ISO-8859-9';
my $char = "\xFE";
print ord $char; # prints 351

How can I get that "351" with Encode.pm?

Note: If I use the letter version (small s with a dot under it "ş")
instead of the "\x" escape, I get the same results...
Note2: ISO-8859-9 == Turkish

<Prev in Thread] Current Thread [Next in Thread>