edis has asked for the wisdom of the Perl Monks concerning the following question:
Both index and regex work here. The problem appears when data comes from sjis encoded file:use utf8; use strict; my $s1 = "long_japanese_text_ i_utf8"; my $s2 = "short_japanese_text_in_utf8"; print index($s1, $s2)."\n"; print "found\n" if $s1 =~ /$s2/;
Neither regex nor index work here. What is the problem? What am I doing wrong? Thanks, Edvinasuse strict; use utf8; my $s1 = "short_japanese_text_in_utf8"; open F, "<:encoding(sjis)", "file.txt"; while (<F>) { print "found\n" if /$s1/; print index($_, $s1)."\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unicode problem
by idsfa (Vicar) on Jun 16, 2005 at 05:48 UTC | |
|
Re: Unicode problem
by mugwumpjism (Hermit) on Jun 16, 2005 at 21:50 UTC | |
|
Re: Unicode problem
by graff (Chancellor) on Jun 17, 2005 at 03:25 UTC | |
|
Re: Unicode problem
by dakkar (Hermit) on Jun 19, 2005 at 09:55 UTC | |
by edis (Acolyte) on Jun 20, 2005 at 01:38 UTC |