From: Roy Ivy III Date: Sat, 9 Mar 2019 05:31:26 +0000 (-0600) Subject: fix Windows EOL translation error with UTF-8 X-Git-Tag: 20190601~12^2^2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5c74780779ad5ec9e6ba0f3e1a629539d902931b;p=perltidy.git fix Windows EOL translation error with UTF-8 .# Discussion When using `binmode ... ":encoding(UTF8)"`, the CRLF translation layer is left in-place. As used prior to this commit, on Windows machines, this `binmode` setting causes the output file to be converted to "DOS" CRLF line endings regardless of other settings. `binmode ... ":raw:encoding(UTF8)"` will enable UTF-8 without the CRLF translation layer. --- diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 543754eb..cfcbdc4c 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -1297,7 +1297,7 @@ EOM if ( $rOpts->{'character-encoding'} && $rOpts->{'character-encoding'} eq 'utf8' ) { - binmode $fout, ":encoding(UTF-8)"; + binmode $fout, ":raw:encoding(UTF-8)"; } else { binmode $fout } } diff --git a/lib/Perl/Tidy/LineSink.pm b/lib/Perl/Tidy/LineSink.pm index 8e3a7c38..7d9f4a14 100644 --- a/lib/Perl/Tidy/LineSink.pm +++ b/lib/Perl/Tidy/LineSink.pm @@ -29,10 +29,10 @@ sub new { && $rOpts->{'character-encoding'} eq 'utf8' ) { if ( ref($fh) eq 'IO::File' ) { - $fh->binmode(":encoding(UTF-8)"); + $fh->binmode(":raw:encoding(UTF-8)"); } elsif ( $output_file eq '-' ) { - binmode STDOUT, ":encoding(UTF-8)"; + binmode STDOUT, ":raw:encoding(UTF-8)"; } }