perl-unicode

Re: converting Japanese chars into their Unicode values using 5.8's Encode

2002-09-19 11:30:06
On Thu, Sep 19, 2002 at 12:35:46AM +0200, Robert Allerstorfer wrote:
        use Encode::JP;
        my $string = "撫";
        Encode::from_to($string, "shiftjis", "utf8");
        my $ord = join("\n", unpack('U*', $string));
        print "$string\n$ord";

But, this gives a 3-character string "璊?" (with the decimal values
230, 164 and 156). Could anyone please point me to the right direction
on how to get the decimal number 26908 instead?

use Encode;
my $string = "日本語";
@codes = map ord, split //, Encode::decode(shiftjis => $string);
print "@codes"; # 26085 26412 35486

/Autrijus/

Attachment: pgpdHe9nXh6xn.pgp
Description: PGP signature

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