note
dakkar
<p>Works for me, Perl 5.8.2 on Linux. I wrote:</p>
<pre>
#!/usr/bin/perl
use utf8;
open my $fh,'<:encoding(sjis)','j.sjis.txt';
my $string='言葉';
print index(<$fh>,$string);
</pre>
<p>saving it as '<tt>j.pl</tt>' as utf-8, and</p>
<pre>
日本語の言葉
</pre>
<p>saving it as '<tt>j.sjis.txt</tt>' as shift-jis.</p>
<p>Running it:</p>
<pre>
$ perl j.pl j.sjis.txt
4
</pre>
<p>(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)</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-43471">
<pre>--
dakkar - Mobilis in mobile
</pre>
<p><font size="-2">Most of my code <em>is</em> tested...</font></p>
<p><font size="-2"><a href="http://www.sidhe.org/~dan/blog/archives/000151.html">Perl is strongly typed, it just has very few types</a> (Dan)</font></p>
</div></div>
467149
467149