perl-unicode

Re: select a variable as stdout and utf8 flag behaviour

2016-11-10 03:33:29
* Gert Brinkmann <g111(_at_)netcologne(_dot_)de> [2016-11-09 16:00]:
open(my $fh, '>:encoding(UTF-8)', \$html);
my $orig_stdout = select( $fh );
print "Ümläut Test ßaß; 使用下列语言\n";

Think of it this way:

Those three lines of code are an elaborate way of doing this:

    $html = Encode::encode('UTF-8', "Ümläut Test ßaß; 使用下列语言\n");

If you wrote that code, would you be surprised that $html does not
have the UTF8 flag set afterwards?

Bonus question if you are not surprised then: what is the difference
between these two cases that makes your argument that “perl knows what
I put in there so it should know to set the UTF8 flag on it” not apply
to this?

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

<Prev in Thread] Current Thread [Next in Thread>