Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binmode (encoding) is not idempotent #10454

Open
p5pRT opened this issue Jun 20, 2010 · 8 comments
Open

binmode (encoding) is not idempotent #10454

p5pRT opened this issue Jun 20, 2010 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 20, 2010

Migrated from rt.perl.org#75890 (status was 'open')

Searchable as RT75890$

@p5pRT
Copy link
Author

p5pRT commented Jun 20, 2010

From @yecril71pl

== Problem description​: ==
The documentation of binmode [8] says that binmode can apply an encoding in
the middle of stream.
However, when I do this, the encoding layers accumulate,
and number of bytes for each extended character increases with each layer. It
is unexpected and not useful.

== Code​: ==
#!/bin/sh
for w in 0 1 2
do echo 'Zażó�� g��l� jaź�.'
done | iconv '-f' 'utf8' '-t' 'latin2' | perl '-w' '-e' '
binmode STDOUT, '\''​:utf8'\'';
while (<>) {
binmode ARGV, '\''​:encoding(ISO-8859-2)'\'';
print $_; }'

== Expected output​: ==
Za¿ó³æ gê¶l± ja¼ñ.
Zażó�� g��l� jaź�.
Zażó�� g��l� jaź�.

== Actual output​: ==
Za¿ó³æ gê¶l± ja¼ñ.
Zażó�� g��l� jaź�.
ZaĹź��Ĺ� g�Ĺ� jaĹ�Ĺ.

== Workaround​: ==
binmode ARGV; binmode ARGV, '\''​:encoding(ISO-8859-2)'\'';

== References​: ==
[8] <URL​:http​://perldoc.perl.org/functions/binmode.html>

Perl Info

Flags:
    category=library
    severity=low

This perlbug was built using Perl 5.10.0 - Wed Mar 24 11:39:55 UTC 2010
It is being executed now by  Perl 5.10.0 - Wed Mar 24 11:34:27 UTC 2010.

Site configuration information for perl 5.10.0:

Configured by abuild at Wed Mar 24 11:34:27 UTC 2010.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.6.31, archname=x86_64-linux-thread-multi
    uname='linux build32 2.6.31 #1 smp 2010-01-06 16:07:25 +0100 x86_64 x86_64 
x86_64 gnulinux '
    config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr -Dinstallusrbinperl 
-Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm -Duseshrplib=true -Doptimize=-
fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-
tables -fasynchronous-unwind-tables -g -Wall -pipe -Accflags=-
DPERL_USE_SAFE_PUTENV'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -
DDEBUGGING -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -
D_FILE_OFFSET_BITS=64',
    optimize='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-
protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -DDEBUGGING -
fno-strict-aliasing -pipe'
    ccversion='', gccversion='4.4.1 [gcc-4_4-branch revision 150839]', 
gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib64'
    libpth=/lib64 /usr/lib64 /usr/local/lib64
    libs=-lm -ldl -lcrypt -lpthread
    perllibs=-lm -ldl -lcrypt -lpthread
    libc=/lib64/libc-2.10.1.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.10.1'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-
rpath,/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib64'

Locally applied patches:
    


@INC for perl 5.10.0:
    /usr/lib/perl5/5.10.0/x86_64-linux-thread-multi
    /usr/lib/perl5/5.10.0
    /usr/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi
    /usr/lib/perl5/site_perl/5.10.0
    /usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.10.0
    /usr/lib/perl5/vendor_perl
    .


Environment for perl 5.10.0:
    HOME=/home/krzysztof
    LANG=pl_PL.UTF-8
    LANGUAGE=
    LD_LIBRARY_PATH=/usr/lib64/mpi/gcc/openmpi/lib64
    LOGDIR (unset)
    PATH=/usr/lib64/mpi/gcc/openmpi/bin:/home/krzysztof/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib64/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jul 30, 2012

From @dmcbride

Created by @dmcbride

This is related to #113982, but not actually the same issue.

Because of the clobbering of PerlIO layers, I inserted some code to ensure
that STDOUT and STDERR always have the correct encoding. However, this
code was being run even when the layers had not been clobbered. This would
result in double-encoding, and then I'd get an error message that was less
than useful.

I would suggest, in increasing order of preference, one of​:

a) Documentation for :raw indicating it is recommended for undoing all
other encodings (or, better, some other way of popping out any encoding
layer(s)), or

b) An error message when an encoding layer is added on top of another
encoding layer, or

b) Clobbering (such as with :raw) old encodings when adding a new
encoding layer.

Code​:

#! /usr/bin/perl

use 5.10.1;

$text = "\x{65E0}\x{6CD5}\x{542F}\x{52A8}";

binmode STDOUT, '​:encoding(eucCN)';
binmode STDOUT, '​:encoding(eucCN)';

say "== $_" for PerlIO​::get_layers(STDOUT);

say $text;

__END__

I'm suggesting that this should produce the same output whether there is
one or both of those binmode statements. Note that if I change the
second binmode to include :raw before :encoding, I get the desired output
(see option (a) above).

(The Perl I'm using this on is 5.10.1, which is not the same as my local
system perl, but this also happens on 5.16.0.)

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.12.4:

Configured by Gentoo at Wed Sep 28 07:02:37 MDT 2011.

Summary of my perl5 (revision 5 version 12 subversion 4) configuration:
   
  Platform:
    osname=linux, osvers=2.6.39-gentoo-r3, archname=x86_64-linux-thread-multi
    uname='linux naboo 2.6.39-gentoo-r3 #1 smp sun jul 17 07:13:38 mdt 2011 x86_64 intel(r) core(tm) i7 cpu 930 @ 2.80ghz genuineintel gnulinux '
    config_args='-des -Duseshrplib -Darchname=x86_64-linux-thread -Dcc=x86_64-pc-linux-gnu-gcc -Doptimize=-O3 -pipe -march=core2 -Dldflags=-Wl,-O1 -Wl,--as-needed -Dprefix=/usr -Dsiteprefix=/usr -Dvendorprefix=/usr -Dscriptdir=/usr/bin -Dprivlib=/usr/lib64/perl5/5.12.4 -Darchlib=/usr/lib64/perl5/5.12.4/x86_64-linux-thread-multi -Dsitelib=/usr/lib64/perl5/site_perl/5.12.4 -Dsitearch=/usr/lib64/perl5/site_perl/5.12.4/x86_64-linux-thread-multi -Dvendorlib=/usr/lib64/perl5/vendor_perl/5.12.4 -Dvendorarch=/usr/lib64/perl5/vendor_perl/5.12.4/x86_64-linux-thread-multi -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/share/man/man1 -Dsiteman3dir=/usr/share/man/man3 -Dvendorman1dir=/usr/share/man/man1 -Dvendorman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dlibperl=libperl.so.5.12.4 -Dlocincpth=  -Duselargefiles -Dd_semctl_semun -Dcf_by=Gentoo -Dmyhostname=localhost -Dperladmin=root@localhost -Dinstallusrbinperl=n -Ud_csh -Uusenm -Di_ndbm -Di_gdbm 
 -Di_db -Dusethreads -DDEBUGGING=none -Dinc_version_list=5.12.3/x86_64-linux-thread-multi 5.12.3 5.12.2/x86_64-linux-thread-multi 5.12.2 5.12.1/x86_64-linux-thread-multi 5.12.1 5.12.0/x86_64-linux-thread-multi 5.12.0  -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='x86_64-pc-linux-gnu-gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O3 -pipe -march=core2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe'
    ccversion='', gccversion='4.5.3', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='x86_64-pc-linux-gnu-gcc', ldflags ='-Wl,-O1 -Wl,--as-needed'
    libpth=/usr/local/lib64 /lib64 /usr/lib64
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.12.2.so, so=so, useshrplib=true, libperl=libperl.so.5.12.4
    gnulibc_version='2.12.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O3 -pipe -march=core2 -Wl,-O1 -Wl,--as-needed'

Locally applied patches:
    0001-gentoo_MakeMaker-RUNPATH.diff
    0002-gentoo_config_over.diff
    0003-gentoo_cpan_definstalldirs.diff
    0004-gentoo_cpanplus_definstalldirs.diff
    0005-gentoo_create-libperl-soname.diff
    0006-gentoo_MakeMaker-delete_packlist.diff
    0007-fixes_8d66b3f9_h2hp_fix.diff
    0008-fixes_f178b03b_h2ph_using_deprecated_goto.diff
    0009-gentoo_mod-paths.diff
    0010-gentoo_enc2xs.diff
    0011-gentoo_IO-Compress_AutoLoader_dropped_from_Compress-Zlib.diff
    0012-gentoo_drop-fstack-protector.diff


@INC for perl 5.12.4:
    /etc/perl
    /usr/lib64/perl5/site_perl/5.12.4/x86_64-linux-thread-multi
    /usr/lib64/perl5/site_perl/5.12.4
    /usr/lib64/perl5/vendor_perl/5.12.4/x86_64-linux-thread-multi
    /usr/lib64/perl5/vendor_perl/5.12.4
    /usr/lib64/perl5/site_perl/5.12.3/x86_64-linux-thread-multi
    /usr/lib64/perl5/site_perl/5.12.3
    /usr/lib64/perl5/site_perl/5.12.2/x86_64-linux-thread-multi
    /usr/lib64/perl5/site_perl/5.12.2
    /usr/lib64/perl5/site_perl
    /usr/lib64/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi
    /usr/lib64/perl5/vendor_perl/5.12.3
    /usr/lib64/perl5/vendor_perl/5.12.2/x86_64-linux-thread-multi
    /usr/lib64/perl5/vendor_perl/5.12.2
    /usr/lib64/perl5/vendor_perl
    /usr/lib64/perl5/5.12.4/x86_64-linux-thread-multi
    /usr/lib64/perl5/5.12.4
    /usr/local/lib/site_perl
    .


Environment for perl 5.12.4:
    HOME=/home/dmcbride
    LANG=en_US.utf8
    LANGUAGE=
    LC_ALL=en_US.utf8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/dmcbride/bin:/usr/lib/distcc/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3:/usr/x86_64-pc-linux-gnu/i686-pc-linux-gnu/gcc-bin/4.5.3:/share/cvs/bin:/usr/local/bin:/usr/games/bin:/share/bin:/share/darin/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2014

From @jkeenan

On Mon Jul 30 15​:26​:17 2012, dmcbride@​cpan.org wrote​:

This is a bug report for perl from dmcbride@​cpan.org,
generated with the help of perlbug 1.39 running under perl 5.12.4.

-----------------------------------------------------------------
[Please describe your issue here]

This is related to #113982, but not actually the same issue.

Because of the clobbering of PerlIO layers, I inserted some code to
ensure
that STDOUT and STDERR always have the correct encoding. However,
this
code was being run even when the layers had not been clobbered. This
would
result in double-encoding, and then I'd get an error message that was
less
than useful.

I would suggest, in increasing order of preference, one of​:

a) Documentation for :raw indicating it is recommended for undoing all
other encodings (or, better, some other way of popping out any
encoding
layer(s)), or

b) An error message when an encoding layer is added on top of another
encoding layer, or

b) Clobbering (such as with :raw) old encodings when adding a new
encoding layer.

Code​:

#! /usr/bin/perl

use 5.10.1;

$text = "\x{65E0}\x{6CD5}\x{542F}\x{52A8}";

binmode STDOUT, '​:encoding(eucCN)';
binmode STDOUT, '​:encoding(eucCN)';

say "== $_" for PerlIO​::get_layers(STDOUT);

say $text;

__END__

I'm suggesting that this should produce the same output whether there
is
one or both of those binmode statements. Note that if I change the
second binmode to include :raw before :encoding, I get the desired
output
(see option (a) above).

(The Perl I'm using this on is 5.10.1, which is not the same as my
local
system perl, but this also happens on 5.16.0.)

Reviewing this older ticket this evening, I had occasion to run the OP's program on perl 5.20.1. Here's what I got?

#####
$ cat 114334-raw.pl
use strict;
use warnings;
use feature 'say';

my $text = "\x{65E0}\x{6CD5}\x{542F}\x{52A8}";

binmode STDOUT, '​:encoding(eucCN)';
binmode STDOUT, '​:encoding(eucCN)';

say "== $_" for PerlIO​::get_layers(STDOUT);

say $text;

$ perl 114334-raw.pl
== unix
== perlio
== encoding(euc-cn)
== utf8
== encoding(euc-cn)
== utf8
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{07b7}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
\x{fffd}\x{07b7}\x{fffd}\x{fffd}\x{fffd}
#####

Can anyone assess the significance of this output in relation to the OP's feature request?

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jan 7, 2017

From @jkeenan

On Mon, 22 Sep 2014 23​:31​:34 GMT, jkeenan wrote​:

On Mon Jul 30 15​:26​:17 2012, dmcbride@​cpan.org wrote​:

This is a bug report for perl from dmcbride@​cpan.org,
generated with the help of perlbug 1.39 running under perl 5.12.4.

-----------------------------------------------------------------
[Please describe your issue here]

This is related to #113982, but not actually the same issue.

Because of the clobbering of PerlIO layers, I inserted some code to
ensure
that STDOUT and STDERR always have the correct encoding. However,
this
code was being run even when the layers had not been clobbered. This
would
result in double-encoding, and then I'd get an error message that was
less
than useful.

I would suggest, in increasing order of preference, one of​:

a) Documentation for :raw indicating it is recommended for undoing
all
other encodings (or, better, some other way of popping out any
encoding
layer(s)), or

b) An error message when an encoding layer is added on top of another
encoding layer, or

b) Clobbering (such as with :raw) old encodings when adding a new
encoding layer.

Code​:

#! /usr/bin/perl

use 5.10.1;

$text = "\x{65E0}\x{6CD5}\x{542F}\x{52A8}";

binmode STDOUT, '​:encoding(eucCN)';
binmode STDOUT, '​:encoding(eucCN)';

say "== $_" for PerlIO​::get_layers(STDOUT);

say $text;

__END__

I'm suggesting that this should produce the same output whether there
is
one or both of those binmode statements. Note that if I change the
second binmode to include :raw before :encoding, I get the desired
output
(see option (a) above).

(The Perl I'm using this on is 5.10.1, which is not the same as my
local
system perl, but this also happens on 5.16.0.)

Reviewing this older ticket this evening, I had occasion to run the
OP's program on perl 5.20.1. Here's what I got?

#####
$ cat 114334-raw.pl
use strict;
use warnings;
use feature 'say';

my $text = "\x{65E0}\x{6CD5}\x{542F}\x{52A8}";

binmode STDOUT, '​:encoding(eucCN)';
binmode STDOUT, '​:encoding(eucCN)';

say "== $_" for PerlIO​::get_layers(STDOUT);

say $text;

$ perl 114334-raw.pl
== unix
== perlio
== encoding(euc-cn)
== utf8
== encoding(euc-cn)
== utf8
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{07b7}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
\x{fffd}\x{07b7}\x{fffd}\x{fffd}\x{fffd}
#####

Can anyone assess the significance of this output in relation to the
OP's feature request?

Re-reviewing this older ticket today, I ran the OP's program on perl-5.24.0.

#####
$ perl 114334-raw.pl
== unix
== perlio
== encoding(euc-cn)
== utf8
== encoding(euc-cn)
== utf8
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{07b7}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
\x{fffd}\x{07b7}\x{fffd}\x{fffd}\x{fffd}
#####

Can anyone assess the significance of this output in relation to the OP's feature request?

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Jan 7, 2017

From @jkeenan

114334-raw.pl

@p5pRT
Copy link
Author

p5pRT commented Jan 7, 2017

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jan 8, 2017

From @Leont

On Sat, Jan 7, 2017 at 4​:21 PM, James E Keenan via RT <
perlbug-followup@​perl.org> wrote​:

On Mon, 22 Sep 2014 23​:31​:34 GMT, jkeenan wrote​:

On Mon Jul 30 15​:26​:17 2012, dmcbride@​cpan.org wrote​:

This is a bug report for perl from dmcbride@​cpan.org,
generated with the help of perlbug 1.39 running under perl 5.12.4.

-----------------------------------------------------------------
[Please describe your issue here]

This is related to #113982, but not actually the same issue.

Because of the clobbering of PerlIO layers, I inserted some code to
ensure
that STDOUT and STDERR always have the correct encoding. However,
this
code was being run even when the layers had not been clobbered. This
would
result in double-encoding, and then I'd get an error message that was
less
than useful.

I would suggest, in increasing order of preference, one of​:

a) Documentation for :raw indicating it is recommended for undoing
all
other encodings (or, better, some other way of popping out any
encoding
layer(s)), or

b) An error message when an encoding layer is added on top of another
encoding layer, or

b) Clobbering (such as with :raw) old encodings when adding a new
encoding layer.

Code​:

#! /usr/bin/perl

use 5.10.1;

$text = "\x{65E0}\x{6CD5}\x{542F}\x{52A8}";

binmode STDOUT, '​:encoding(eucCN)';
binmode STDOUT, '​:encoding(eucCN)';

say "== $_" for PerlIO​::get_layers(STDOUT);

say $text;

__END__

I'm suggesting that this should produce the same output whether there
is
one or both of those binmode statements. Note that if I change the
second binmode to include :raw before :encoding, I get the desired
output
(see option (a) above).

(The Perl I'm using this on is 5.10.1, which is not the same as my
local
system perl, but this also happens on 5.16.0.)

Reviewing this older ticket this evening, I had occasion to run the
OP's program on perl 5.20.1. Here's what I got?

#####
$ cat 114334-raw.pl
use strict;
use warnings;
use feature 'say';

my $text = "\x{65E0}\x{6CD5}\x{542F}\x{52A8}";

binmode STDOUT, '​:encoding(eucCN)';
binmode STDOUT, '​:encoding(eucCN)';

say "== $_" for PerlIO​::get_layers(STDOUT);

say $text;

$ perl 114334-raw.pl
== unix
== perlio
== encoding(euc-cn)
== utf8
== encoding(euc-cn)
== utf8
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{07b7}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
\x{fffd}\x{07b7}\x{fffd}\x{fffd}\x{fffd}
#####

Can anyone assess the significance of this output in relation to the
OP's feature request?

Re-reviewing this older ticket today, I ran the OP's program on
perl-5.24.0.

#####
$ perl 114334-raw.pl
== unix
== perlio
== encoding(euc-cn)
== utf8
== encoding(euc-cn)
== utf8
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{07b7}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
"\x{fffd}" does not map to euc-cn at 114334-raw.pl line 12.
\x{fffd}\x{07b7}\x{fffd}\x{fffd}\x{fffd}
#####

Can anyone assess the significance of this output in relation to the OP's
feature request?

Thank you very much.

The current behavior is not helpful. Making pushing an :encoding(foo) on
top of another :encoding(foo) a no-op is obvious and safe, but what to do
with non-matching :encodings? But what to do about :utf8​:encoding? And what
to do about :encoding :crlf​:encoding? I'd argue the first should pop off
the existing layer, and the latter two is a no-op.

Leon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants