in reply to How to count string length with latin characters?
You have basically 2 ways of dealing with this: only allow submissions in latin-1 (which is the default perl character encoding) using the "accept-charset" property on the <form> tag, or make sure perl knows about your encoding:
There is a LOT of subtle stuff going on here. You should probably read Encode first. Maybe.use Encode qw(decode); my $real_string = decode("utf8",$input_string); #assumes $input string + is in UTF-8 encoding print "string is ".lenght($real_string)." characters\n"; # length() no +w interprets $real_string in character instead of bytes.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to count string length with latin characters?
by rhesa (Vicar) on Nov 02, 2006 at 01:07 UTC | |
by Joost (Canon) on Nov 02, 2006 at 01:34 UTC |