develooper Front page | perl.perl5.porters | Postings from October 2016

Re: [PATCH] Update documentation about UTF-8

Thread Next
From:
pali
Date:
October 23, 2016 04:01
Subject:
Re: [PATCH] Update documentation about UTF-8
Message ID:
201610221213.44130@pali
From e071defa6da6c60232e429522a7918fcc3b71fe2 Mon Sep 17 00:00:00 2001
From: Pali <pali@cpan.org>
Date: Sun, 18 Sep 2016 17:21:54 +0200
Subject: [PATCH v2 03/10] pod: Do not suggest to use Encode::encode_utf8()
 when you need to know the byte length of a string

Encode module could do some additional operations and bytes pragma is
supposed to do that job.
---
 pod/perluniintro.pod |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/pod/perluniintro.pod b/pod/perluniintro.pod
index 0e3f4bc..9b6c0da 100644
--- a/pod/perluniintro.pod
+++ b/pod/perluniintro.pod
@@ -726,14 +726,11 @@ the output string will be UTF-8-encoded C<ab\x80c = \x{100}\n>, but
 C<$a> will stay byte-encoded.
 
 Sometimes you might really need to know the byte length of a string
-instead of the character length. For that use either the
-C<Encode::encode_utf8()> function or the C<bytes> pragma
+instead of the character length. For that use the C<bytes> pragma
 and the C<length()> function:
 
     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 also print 2
                                   # (the 0xC4 0x80 of the UTF-8)
-- 
1.7.9.5


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About