perl-unicode

converting SJIS to UTF-8

2001-01-03 19:32:05


Based on the perl unicode faq, I expected this to work:

sub shift_jis_to_utf8 {
    my ($shift_jis) = @_;

    my $encoding = 'Shift-JIS';
    my $Map = new Unicode::Map({ ID => $encoding });
    my $map_out = $Map->to_unicode($shift_jis);
    my $us = Unicode::String->new($map_out);
    my $us_utf8 = $us->utf8;

    return $us_utf8;
}

but it doesn't.  What's the right way to convert SJIS to UTF-8 with perl?


Thanks,
Chris

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