Change 16176 by jhi@alpha on 2002/04/26 01:22:04

        Subject: [PATCH doc] bytes::length TIMTOWTDI
        From: [EMAIL PROTECTED] (Andreas J. Koenig)
        Date: Tue, 23 Apr 2002 04:40:42 +0200      
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

.... //depot/perl/pod/perluniintro.pod#32 edit

Differences ...

==== //depot/perl/pod/perluniintro.pod#32 (text) ====
Index: perl/pod/perluniintro.pod
--- perl/pod/perluniintro.pod.~1~       Thu Apr 25 19:30:06 2002
+++ perl/pod/perluniintro.pod   Thu Apr 25 19:30:06 2002
@@ -624,13 +624,16 @@
 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<bytes> pragma
-and its only defined function C<length()>:
+instead of the character length. For that use either the
+C<Encode::encode_utf8()> function or the C<bytes> pragma and its only
+defined function C<length()>:
 
     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 
 
End of Patch.

Reply via email to