Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Matching non-ASCII file contents with file name.

by mldvx4 (Friar)
on Dec 23, 2022 at 06:39 UTC ( [id://11149041] : note . print w/replies, xml ) Need Help??


in reply to Re: Matching non-ASCII file contents with file name.
in thread Matching non-ASCII file contents with file name.

Thanks, again!

I see now the mistake but don't understand it. The following is what I had but which was not producing the right result:

my ($fh, $tempfile) = tempfile(); binmode( $fh, ":utf8" );

With your corrections, the following produces the right character:

my ($fh, $tempfile) = tempfile(); binmode( $fh, ":encoding(UTF-8)" );

What would be the difference between binmode( $fh, ":utf8" ); and binmode( $fh, ":encoding(UTF-8)" ); in regards to the output? I don't understand the difference.

Replies are listed 'Best First'.
Re^3: Matching non-ASCII file contents with file name.
by Corion (Patriarch) on Dec 23, 2022 at 07:16 UTC

    Maybe the problem is elsewhere? Because binmode says:

    To mark FILEHANDLE as UTF-8, use :utf8 or :encoding(UTF-8). :utf8 just marks the data as UTF-8 without further checking, while :encoding(UTF-8) checks the data for actually being valid UTF-8.

    I read this as that the two should behave identical (except for warnings). Maybe someone else knows where the differences come from.