develooper Front page | perl.perl5.porters | Postings from February 2012

[perl #109828] PerlIO::scalar does not handle UTF-8

Thread Next
From:
David Leadbeater
Date:
February 4, 2012 09:10
Subject:
[perl #109828] PerlIO::scalar does not handle UTF-8
Message ID:
rt-3.6.HEAD-14510-1328375441-292.109828-75-0@perl.org
# New Ticket Created by  David Leadbeater 
# Please include the string:  [perl #109828]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=109828 >


If a UTF-8 output layer is specified the resulting scalar does not have the UTF-8 flag on.

I think this makes sense for output, although there may be other ramifications.

Here's a todo test:

diff --git a/ext/PerlIO-scalar/t/scalar.t b/ext/PerlIO-scalar/t/scalar.t
index a02107b..59b65ad 100644
--- a/ext/PerlIO-scalar/t/scalar.t
+++ b/ext/PerlIO-scalar/t/scalar.t
@@ -16,7 +16,7 @@ use Fcntl qw(SEEK_SET SEEK_CUR SEEK_END); # Not 0, 1, 2 everywhere.
 
 $| = 1;
 
-use Test::More tests => 79;
+use Test::More tests => 80;
 
 my $fh;
 my $var = "aaa\n";
@@ -360,3 +360,11 @@ SKIP: {
     ok has_trailing_nul $memfile,
         'write appends null when growing string after seek past end';
 }
+
+# [perl #xxxx]
+{
+  local $TODO = "UTF-8 support";
+  my $string = "\x{ffe}";
+  open my $fh, "> :encoding(UTF-8)", \(my $out);
+  ok $string eq $out;
+}


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