From: Andreas König Date: Tue, 23 Apr 2002 04:40:42 +0000 (+0200) Subject: bytes::length TIMTOWTDI X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ce7675db8f37818266339c651f185b6e1a6af2c8;p=p5sagit%2Fp5-mst-13.2.git bytes::length TIMTOWTDI Message-ID: p4raw-id: //depot/perl@16176 --- diff --git a/pod/perluniintro.pod b/pod/perluniintro.pod index 84bfb98..d6eae60 100644 --- a/pod/perluniintro.pod +++ b/pod/perluniintro.pod @@ -624,13 +624,16 @@ the output string will be UTF-8-encoded "ab\x80c\x{100}\n", but note that C<$a> will stay single byte encoded. Sometimes you might really need to know the byte length of a string -instead of the character length. For that use the C pragma -and its only defined function C: +instead of the character length. For that use either the +C function or the C pragma and its only +defined function C: my $unicode = chr(0x100); print length($unicode), "\n"; # will print 1 + require Encode; + print length(Encode::encode_utf8($unicode)), "\n"; # will print 2 use bytes; - print length($unicode), "\n"; # will print 2 (the 0xC4 0x80 of the UTF-8) + print length($unicode), "\n"; # will also print 2 (the 0xC4 0x80 of the UTF-8) =item