in reply to bug? duped filehandles and unicode

update: I didn't spot your PERL_UNICODE remark. Ignore the two paragraphs below

If you have a recent perl (5.8.5ish 5.8.1 or higher) I'm pretty sure your original file handles are NOT marked as utf-8, since there is no way they will be set to utf-8 automatically.

Observe: (this is perl 5.8.8 with $LANG=en_US.UTF-8 on an xterm in utf8 mode):

$ perl -e'print "\x{2639}"' Wide character in print at -e line 1. ☹

But yeah, it seems strange that duplicating a filehandle doesn't copy its encoding. On the other hand, if you open() a file without explicitly setting an encoding it defaults to the systems default 8-bit encoding (see perluniintro and perlopentut), so there's something to be said for the current behaviour.

Also, PerlIO::get_layers is (probably) correct. You don't see the utf8 layer because it's not set (see above).

update2: about that get_layers issue: it seems to work correctly for me (taking into account that layers won't be copied):

PERL_UNICODE=SDL perl -e'print PerlIO::get_layers(STDOUT)' unixperlioutf8