On Sun, 23 Sep 2001 12:40:26 +0330
"Abdolreza Pirshayan" <[EMAIL PROTECTED]> wrote:
> hello,
> I'm using perl 5.6 on a Red Hat Linux 6.2 and have the following problem 
> with using utf-8 encoding:
> 
> in my cgi program the "length()" function does not work correctly with utf-8 
> if the input string is the parameter passed (by get method for instance) 
> from an html form(in this case "length()" will return the number of bytes 
> instead the length of the string) else it works correctly.
> 
> please tell me what should I do to solve this problem?

You can convert a string into one with the UTF8 flag.

    $str = pack 'U*', unpack 'U0U*', $str;

If you have some interest in Perl 5.7 (or later),
try the utf8::decode() function.

There are some other ways to flag a string as UTF8,
but one needs an XS code;
one doesn't work on later versions....

Regards, SADAHIRO Tomoyuki

Reply via email to