Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Lost in utf8 (still..)

by pcouderc (Monk)
on Jun 09, 2016 at 10:22 UTC ( [id://1165214]=perlquestion: print w/replies, xml ) Need Help??

pcouderc has asked for the wisdom of the Perl Monks concerning the following question:

On an utf8 linux, I execute :

#!/usr/bin/perl require 5.0022; use strict; use warnings; use utf8; open STDERR,">:utf8","perl.log"; print STDERR "******************* lost.pl (&é'-è_çà) \n"; binmode(STDERR, ":utf8"); print STDERR "******************* lost.pl (&é'-è_çà) \n";

and I "cat perl.log" :

******************* lost.pl (&?'-?_??) ******************* lost.pl (&é'-è_çà)

I do not understand why the 2 lines of result are different.
Thank you, o brave monks to show me the light.
PC

Replies are listed 'Best First'.
Re: Lost in utf8 (still..)
by choroba (Cardinal) on Jun 09, 2016 at 10:45 UTC
    It seems to work if you replace STDERR with LOG (and open it before) or a lexical filehandle. I can't find anything related to STDERR in the documentation related to this, only maybe

    > To (re)open "STDOUT" or "STDERR" as an in-memory file, close it first

    in open, but there's no in-memory file here.

    BTW, there hasn't been any Perl 5.2.200 (check perlhist):

    Larry 5.002 1996-Feb-29 Prototypes. Charles 5.002_01 1996-Mar-25 5.003 1996-Jun-25 Security release.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      Well, thank you. What is sure is that if close STDERR before the open the 2 result lines are identical ! So if I do not close STDERR, the open is well done but, it seems, not in UTF8.

        You may try to put it as bug report. It is certainly not logical to do the reopening of STDERR without respect to the mode argument in this reopening.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1165214]
Approved by Discipulus
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-20 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found