Package: perl-doc
Version: 5.10.1-18
Severity: wishlist
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.
$ perldoc -f length
length EXPR
length Returns the length in characters of the value of EXPR. If EXPR
is omitted, returns length of
$_. Note that this cannot be used on an entire array or hash to
find out how many elements
these have. For that, use "scalar @array" and "scalar keys
%hash" respectively.
Note the characters: if the EXPR is in Unicode, you will get the
number of characters, not
the number of bytes. To get the length of the internal string
in bytes, use
"bytes::length(EXPR)", see bytes. Note that the internal
encoding is variable, and the
number of bytes usually meaningless. To get the number of bytes
that the string would have
when encoded as UTF-8, use "length(Encoding::encode_utf8(EXPR))".
$ perl -wle 'print length "網路;"'
9
$ perl -wle 'print length "網路"'
6
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]