From: "Dr.Ruud" <[EMAIL PROTECTED]>

"Octavian Rasnita" schreef:
I have also seen that length($string) returns the number of bytes of
$string, and not the number of chars (if the string contains UTF-8
chars).

This tells me that you are taking input from an octet buffer that comes
from outside.

Yes, I am getting it from a SQLite database.

   my $octets = <>;
   my $string;
   eval {
       $string = Encode::decode("utf8", $octets, Encode::FB_CROAK);
       1;
   } or {
       # malformed input
   }


Ok, I can get the size of the string using this code, but please tell me how to get the UTF-8 chars from this string.

After decoding the octets, if I do

my @chars = split //, $string;

then it also returns the octets separately and not the UTF-8 chars.

Thanks.

Octavian


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to