in reply to Re^2: binmode, encoding layer, ignoring encoding problems
in thread binmode, encoding layer, ignoring encoding problems
open my $fh, ">", "output.txt" or die $!; print $fh encode('latin-1', $euro_in_unicode), "\n"; close $fh;
Update: Taking a hint from the source, the following seems to work. No idea what STOP_AT_PARTIAL means.
#!/usr/bin/perl use strict; use warnings; use PerlIO::encoding; use Encode; my $euro_in_unicode = chr(0x20AC); open my $fh, ">", "output.txt" or die $!; { local $PerlIO::encoding::fallback = Encode::FB_DEFAULT|Encode::STOP_AT_PARTIAL; binmode $fh, ":encoding(latin1)"; } print $fh "$euro_in_unicode\n"; close $fh;
|
|---|