in reply to How to count string length with latin characters?

I'm confused. There are 40 characters in that string!

Note too that the characters you have posted render as utf-8 characters (at least for me).

The following may help however:

use strict; use warnings; use Encode; my $str = "הההההההההההההההההההההההההההההההההההההההה"; print 'Raw: ' . length $str; print "\nDecoded: " . length decode ('utf8', $str);

Prints:

Raw: 80 Decoded: 40

If the encoding you are using really is latin1 then using decode ('iso-8859-1', $str) may turn the trick for you.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: How to count string length with latin characters?
by newblet (Novice) on Nov 02, 2006 at 00:17 UTC
    ah stupid me... sorry i meant 40 but results in 80, not 20 to 40 :) thanks for the input guys i'm gonna look into your help a little more and see how this works out, thanks again.