http://qs321.pair.com?node_id=468087


in reply to Unicode problem

Works for me, Perl 5.8.2 on Linux. I wrote:

#!/usr/bin/perl
use utf8;

open my $fh,'<:encoding(sjis)','j.sjis.txt';
my $string='言葉';
print index(<$fh>,$string);

saving it as 'j.pl' as utf-8, and

日本語の言葉

saving it as 'j.sjis.txt' as shift-jis.

Running it:

$ perl j.pl j.sjis.txt
4

(yes, I used <pre> instead of <code>... but <code> would not let me use character entities, and without the proper characters this answer would be useless)

-- 
        dakkar - Mobilis in mobile

Most of my code is tested...

Perl is strongly typed, it just has very few types (Dan)

Replies are listed 'Best First'.
Re^2: Unicode problem
by edis (Acolyte) on Jun 20, 2005 at 01:38 UTC
    Sorry, it was my fault, the short lookup string was incorrect (I can't read Japanese, but need to work with it). Everything works fine now.

    Thanks all for the help.

    Edvinas