jida...@jidanni.org writes:

> It says

>                Note the characters: if the EXPR is in Unicode, you will
>                get the number of characters, not the number of bytes.

> But I prove it wrong below.

> $ perl -wle 'print length "網路;"'
> 9
> $ perl -wle 'print length "網路"'
> 6

Those aren't Unicode strings.  They're strings of bytes, and hence the
behavior is as described in the documentation.  If you want to put a
literal Unicode string into Perl source, you have to add "use utf8" to
change the default interpretation, after which you get the behavior that
you're expecting.

windlord:~> perl -wle 'use utf8; print length "網路;"'
3
windlord:~> perl -wle 'use utf8; print length "網路"'
2

-- 
Russ Allbery (r...@debian.org)               <http://www.eyrie.org/~eagle/>



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to