Skip Menu |
 

This queue is for tickets about the Perl-Tidy CPAN distribution.

Report information

Subject: Broken handling of UTF-8 strings
Download (untitled) / with headers
text/plain 460b
Hi. I can't get Perl::Tidy to do the right thing with UTF-8 strings. I've attached a test case with a source file (test.pl), the expected output (want.pl.tdy) and the actual output (got.pl.tdy). The problem arises because Perl::Tidy considers "Für" to be 4 characters rather than 3, courtesy of length(), which returns the number of bytes rather than the number of characters, unless the string "is in Unicode". perl 5.8.8 Linux 2.6.22 Perl::Tidy 20071205
Subject: test.pl
Download test.pl
text/x-perl 90b
my $test = [ "Für Elise" => "Beethoven", "Eine kleine Nachtmusik" => "Mozart" ];
Subject: want.pl.tdy
Download want.pl.tdy
application/octet-stream 103b

Message body not shown because it is not plain text.

Subject: got.pl.tdy
Download got.pl.tdy
application/octet-stream 102b

Message body not shown because it is not plain text.

Download (untitled) / with headers
text/plain 579b
On Sun Feb 03 23:42:09 2008, CHOCOLATE wrote: Show quoted text
> Hi. > > I can't get Perl::Tidy to do the right thing with UTF-8 strings. > > I've attached a test case with a source file (test.pl), the expected > output (want.pl.tdy) and the actual output (got.pl.tdy). > > The command was perltidy -fnl test.pl > > The problem arises because Perl::Tidy considers "Für" to be 4 characters > rather than 3, courtesy of length(), which returns the number of bytes > rather than the number of characters, unless the string "is in Unicode". > > perl 5.8.8 > Linux 2.6.22 > Perl::Tidy 20071205
Download (untitled) / with headers
text/plain 307b
I think this is no bug as long as you do not "use utf8", because the strings should be interpreted as byte strings then. perltidy, however, does not seem to honor "use utf8" yet, so the indentation will still be incorrect despite this pragma being in effect, which I consider a bug, too. :-) Regards, fany
From: sebastian [...] podjasek.pl
Download (untitled) / with headers
text/plain 285b
On Nd 07 Gru 2008, 09:10:15, FANY wrote: Show quoted text
> perltidy, however, does not seem to honor "use utf8" yet, so the > indentation will still be incorrect despite this pragma being in effect, > which I consider a bug, too. :-)
Just a tiny little change which solves this bug - at least for me.
Subject: 0001-Fix-indentation-of-wide-characters.patch
From 203ea7adfd66a00ebb104af882c4d96faf244230 Mon Sep 17 00:00:00 2001 From: Sebastian Podjasek <sebastian@podjasek.pl> Date: Tue, 13 May 2014 08:43:07 +0200 Subject: [PATCH] Fix indentation of wide-characters --- lib/Perl/Tidy.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index c326a8f..19b92bd 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -165,6 +165,7 @@ EOM } $fh = $New->( $filename, $mode ) or Warn("Couldn't open file:$filename in mode:$mode : $!\n"); + $fh->binmode(':utf8'); return $fh, ( $ref or $filename ); } -- 1.9.1
Subject: Re: [rt.cpan.org #32905] Broken handling of UTF-8 strings
Date: Tue, 13 May 2014 06:37:10 -0700
To: "bug-Perl-Tidy [...] rt.cpan.org" <bug-Perl-Tidy [...] rt.cpan.org>
From: Steven Hancock <s7078hancock [...] gmail.com>
Download (untitled) / with headers
text/plain 509b
Sebastian, thanks. Steve On Tuesday, May 13, 2014, Sebastian Podjasek via RT < bug-Perl-Tidy@rt.cpan.org> wrote: Show quoted text
> Queue: Perl-Tidy > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=32905 > > > On Nd 07 Gru 2008, 09:10:15, FANY wrote:
> > perltidy, however, does not seem to honor "use utf8" yet, so the > > indentation will still be incorrect despite this pragma being in effect, > > which I consider a bug, too. :-)
> > Just a tiny little change which solves this bug - at least for me. >
From: sebastian [...] podjasek.pl
Download (untitled) / with headers
text/plain 180b
Previous patch would cause problems when using Perl::Tidy with string as an argument (Perl::Tidy::IOScalar does not implement binmode method). Also added some tests for this issue.
Subject: 0001-Fix-indentation-of-wide-characters.patch
From c572d03d038eb2c9cb663b2484ae48cef35073ce Mon Sep 17 00:00:00 2001 From: Sebastian Podjasek <sebastian.podjasek@intelliway.pl> Date: Tue, 13 May 2014 08:43:07 +0200 Subject: [PATCH] Fix indentation of wide-characters --- lib/Perl/Tidy.pm | 1 + t/testwide.pl.src | 4 ++++ t/testwide.t | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 t/testwide.pl.src create mode 100644 t/testwide.t diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index c326a8f..69d2788 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -165,6 +165,7 @@ EOM } $fh = $New->( $filename, $mode ) or Warn("Couldn't open file:$filename in mode:$mode : $!\n"); + $fh->binmode(':utf8') if $fh->can('binmode'); return $fh, ( $ref or $filename ); } diff --git a/t/testwide.pl.src b/t/testwide.pl.src new file mode 100644 index 0000000..10eec3a --- /dev/null +++ b/t/testwide.pl.src @@ -0,0 +1,4 @@ +%pangrams=("Plain","ASCII", +"Zwölf große Boxkämpfer jagen Vik quer über den Sylter.","DE", +"Jeż wlókł gęś. Uf! Bądź choć przy nim, stań!","PL", +"Любя, съешь щипцы, — вздохнёт мэр, — кайф жгуч.","RU"); \ No newline at end of file diff --git a/t/testwide.t b/t/testwide.t new file mode 100644 index 0000000..e96dfdd --- /dev/null +++ b/t/testwide.t @@ -0,0 +1,48 @@ +use strict; +use utf8; +use Test; +use Carp; +use FindBin; +BEGIN {plan tests => 2} +use Perl::Tidy; + + +my $source = <<'EOM'; +%pangrams=("Plain","ASCII", +"Zwölf große Boxkämpfer jagen Vik quer über den Sylter.","DE", +"Jeż wlókł gęś. Uf! Bądź choć przy nim, stań!","PL", +"Любя, съешь щипцы, — вздохнёт мэр, — кайф жгуч.","RU"); +EOM + +my $expected_output=<<'EOM'; +%pangrams = ( + "Plain", "ASCII", + "Zwölf große Boxkämpfer jagen Vik quer über den Sylter.", "DE", + "Jeż wlókł gęś. Uf! Bądź choć przy nim, stań!", "PL", + "Любя, съешь щипцы, — вздохнёт мэр, — кайф жгуч.", "RU" + ); +EOM + +my $perltidyrc = <<'EOM'; +-gnu +EOM + +my $output; + +Perl::Tidy::perltidy( + source => \$source, + destination => \$output, + perltidyrc => \$perltidyrc, + argv => '-nsyn', +); + +ok($output, $expected_output); + +Perl::Tidy::perltidy( + source => $FindBin::Bin . '/testwide.pl.src', + destination => \$output, + perltidyrc => \$perltidyrc, + argv => '-nsyn', +); + +ok($output, $expected_output); -- 1.9.1
Subject: Re: [rt.cpan.org #32905] Broken handling of UTF-8 strings
Date: Sat, 26 Jul 2014 16:38:52 -0700
To: "bug-Perl-Tidy [...] rt.cpan.org" <bug-Perl-Tidy [...] rt.cpan.org>
From: Steven Hancock <s7078hancock [...] gmail.com>
Download (untitled) / with headers
text/plain 699b
Sebastian, Thanks for the updated patch. I would be interested in putting this in to the next release on an experimental basis, but at least for now it would have to be turned on with a flag since otherwise it will cause problems with some existing scripts. Do you have a suggested name for the flag? Thanks, Steve On Fri, Jul 25, 2014 at 12:59 AM, Sebastian Podjasek via RT < bug-Perl-Tidy@rt.cpan.org> wrote: Show quoted text
> Queue: Perl-Tidy > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=32905 > > > Previous patch would cause problems when using Perl::Tidy with string as > an argument (Perl::Tidy::IOScalar does not implement binmode method). Also > added some tests for this issue. >
From: sebastian [...] podjasek.pl
Download (untitled) / with headers
text/plain 199b
On Sob 26 Lip 2014, 19:39:07, s7078hancock@gmail.com wrote: Show quoted text
> Do you have a suggested name for the flag?
-wide / --wide-chars seems to be related to issue solved. As I've seen -wc is already taken.
Subject: Re: [rt.cpan.org #32905] Broken handling of UTF-8 strings
Date: Sat, 8 Nov 2014 05:30:35 -0800
To: "bug-Perl-Tidy [...] rt.cpan.org" <bug-Perl-Tidy [...] rt.cpan.org>
From: Steven Hancock <s7078hancock [...] gmail.com>
Download (untitled) / with headers
text/plain 463b
That seems okay, or even -wch / --wide-characters Steve On Fri, Nov 7, 2014 at 4:00 PM, Sebastian Podjasek via RT < bug-Perl-Tidy@rt.cpan.org> wrote: Show quoted text
> Queue: Perl-Tidy > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=32905 > > > On Sob 26 Lip 2014, 19:39:07, s7078hancock@gmail.com wrote:
> > Do you have a suggested name for the flag?
> > -wide / --wide-chars > > seems to be related to issue solved. As I've seen -wc is already taken. >
Download (untitled) / with headers
text/plain 1.7k
Here is the more portable solution, that works with any source type (ScalarRef, handle, ArrayRef). --- "d:\\downloads\\Tidy.pm" 2015-08-15 03:18:51.000000000 +0300 +++ "d:\\devel\\perl\\perl\\site\\lib\\Perl\\Tidy.pm" 2015-08-15 07:47:21.570789700 +0300 @@ -173,12 +173,6 @@ $fh = $New->( $filename, $mode ) or Warn("Couldn't open file:$filename in mode:$mode : $!\n"); - # The first call here will be to read the config file, which is before - # the --encoding has been set, so the config file cannot be read as utf8 - $fh->binmode(':encoding(utf8)') - if ( $rOpts_character_encoding - && $rOpts_character_encoding eq 'utf8' - && $fh->can('binmode') ); return $fh, ( $ref or $filename ); } @@ -811,12 +805,23 @@ # Prefilters and postfilters: The prefilter is a code reference # that will be applied to the source before tidying, and the # postfilter is a code reference to the result before outputting. - if ($prefilter) { + if ( $prefilter || ( $rOpts_character_encoding && $rOpts_character_encoding eq 'utf8' ) ) { my $buf = ''; while ( my $line = $source_object->get_line() ) { $buf .= $line; } - $buf = $prefilter->($buf); + + $buf = $prefilter->($buf) if $prefilter; + + if ( $rOpts_character_encoding && $rOpts_character_encoding eq 'utf8' && !utf8::is_utf8($buf) ) { + require Encode; + + eval { + $buf = Encode::decode('UTF-8', $buf, Encode::FB_CROAK | Encode::LEAVE_SRC); + }; + + Die "unable to decode source\n" if $@; + } $source_object = Perl::Tidy::LineSource->new( \$buf, $rOpts, $rpending_logfile_message );
Subject: patch.txt
Download patch.txt
text/plain 1.6k
--- "d:\\downloads\\Tidy.pm" 2015-08-15 03:18:51.000000000 +0300 +++ "d:\\devel\\perl\\perl\\site\\lib\\Perl\\Tidy.pm" 2015-08-15 07:47:21.570789700 +0300 @@ -173,12 +173,6 @@ $fh = $New->( $filename, $mode ) or Warn("Couldn't open file:$filename in mode:$mode : $!\n"); - # The first call here will be to read the config file, which is before - # the --encoding has been set, so the config file cannot be read as utf8 - $fh->binmode(':encoding(utf8)') - if ( $rOpts_character_encoding - && $rOpts_character_encoding eq 'utf8' - && $fh->can('binmode') ); return $fh, ( $ref or $filename ); } @@ -811,12 +805,23 @@ # Prefilters and postfilters: The prefilter is a code reference # that will be applied to the source before tidying, and the # postfilter is a code reference to the result before outputting. - if ($prefilter) { + if ( $prefilter || ( $rOpts_character_encoding && $rOpts_character_encoding eq 'utf8' ) ) { my $buf = ''; while ( my $line = $source_object->get_line() ) { $buf .= $line; } - $buf = $prefilter->($buf); + + $buf = $prefilter->($buf) if $prefilter; + + if ( $rOpts_character_encoding && $rOpts_character_encoding eq 'utf8' && !utf8::is_utf8($buf) ) { + require Encode; + + eval { + $buf = Encode::decode('UTF-8', $buf, Encode::FB_CROAK | Encode::LEAVE_SRC); + }; + + Die "unable to decode source\n" if $@; + } $source_object = Perl::Tidy::LineSource->new( \$buf, $rOpts, $rpending_logfile_message );
Subject: Re: [rt.cpan.org #32905] Broken handling of UTF-8 strings
Date: Sat, 15 Aug 2015 06:58:21 -0700
To: "bug-Perl-Tidy [...] rt.cpan.org" <bug-Perl-Tidy [...] rt.cpan.org>
From: Steven Hancock <s7078hancock [...] gmail.com>
Download (untitled) / with headers
text/plain 4.5k
Dmytro, Thanks for the patch, this looks like a better way to go. I changed the 'require' to 'use' to get it to work without complaints. When I tested it on a file I noticed that the output file was not UTF-8 on my system, so I think that the previous coding may need to be retained when the $mode is write. Any other comments are very welcome. I assume that I will be getting more suggestions for improvement once this version starts to get used, so I will probably need to do another release fairly soon. Steve On Fri, Aug 14, 2015 at 9:56 PM, Dmytro Zagashev via RT < bug-Perl-Tidy@rt.cpan.org> wrote: Show quoted text
> Queue: Perl-Tidy > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=32905 > > > Here is the more portable solution, that works with any source type > (ScalarRef, handle, ArrayRef). > > --- "d:\\downloads\\Tidy.pm" 2015-08-15 03:18:51.000000000 +0300 > +++ "d:\\devel\\perl\\perl\\site\\lib\\Perl\\Tidy.pm" 2015-08-15 > 07:47:21.570789700 +0300 > @@ -173,12 +173,6 @@ > $fh = $New->( $filename, $mode ) > or Warn("Couldn't open file:$filename in mode:$mode : $!\n"); > > - # The first call here will be to read the config file, which is before > - # the --encoding has been set, so the config file cannot be read as > utf8 > - $fh->binmode(':encoding(utf8)') > - if ( $rOpts_character_encoding > - && $rOpts_character_encoding eq 'utf8' > - && $fh->can('binmode') ); > return $fh, ( $ref or $filename ); > } > > @@ -811,12 +805,23 @@ > # Prefilters and postfilters: The prefilter is a code reference > # that will be applied to the source before tidying, and the > # postfilter is a code reference to the result before outputting. > - if ($prefilter) { > + if ( $prefilter || ( $rOpts_character_encoding && > $rOpts_character_encoding eq 'utf8' ) ) { > my $buf = ''; > while ( my $line = $source_object->get_line() ) { > $buf .= $line; > } > - $buf = $prefilter->($buf); > + > + $buf = $prefilter->($buf) if $prefilter; > + > + if ( $rOpts_character_encoding && > $rOpts_character_encoding eq 'utf8' && !utf8::is_utf8($buf) ) { > + require Encode; > + > + eval { > + $buf = Encode::decode('UTF-8', > $buf, Encode::FB_CROAK | Encode::LEAVE_SRC); > + }; > + > + Die "unable to decode source\n" if $@; > + } > > $source_object = Perl::Tidy::LineSource->new( \$buf, $rOpts, > $rpending_logfile_message ); > > --- "d:\\downloads\\Tidy.pm" 2015-08-15 03:18:51.000000000 +0300 > +++ "d:\\devel\\perl\\perl\\site\\lib\\Perl\\Tidy.pm" 2015-08-15 > 07:47:21.570789700 +0300 > @@ -173,12 +173,6 @@ > $fh = $New->( $filename, $mode ) > or Warn("Couldn't open file:$filename in mode:$mode : $!\n"); > > - # The first call here will be to read the config file, which is before > - # the --encoding has been set, so the config file cannot be read as > utf8 > - $fh->binmode(':encoding(utf8)') > - if ( $rOpts_character_encoding > - && $rOpts_character_encoding eq 'utf8' > - && $fh->can('binmode') ); > return $fh, ( $ref or $filename ); > } > > @@ -811,12 +805,23 @@ > # Prefilters and postfilters: The prefilter is a code reference > # that will be applied to the source before tidying, and the > # postfilter is a code reference to the result before outputting. > - if ($prefilter) { > + if ( $prefilter || ( $rOpts_character_encoding && > $rOpts_character_encoding eq 'utf8' ) ) { > my $buf = ''; > while ( my $line = $source_object->get_line() ) { > $buf .= $line; > } > - $buf = $prefilter->($buf); > + > + $buf = $prefilter->($buf) if $prefilter; > + > + if ( $rOpts_character_encoding && > $rOpts_character_encoding eq 'utf8' && !utf8::is_utf8($buf) ) { > + require Encode; > + > + eval { > + $buf = Encode::decode('UTF-8', > $buf, Encode::FB_CROAK | Encode::LEAVE_SRC); > + }; > + > + Die "unable to decode source\n" if $@; > + } > > $source_object = Perl::Tidy::LineSource->new( \$buf, $rOpts, > $rpending_logfile_message ); > >
From: qsimpleq
Download (untitled) / with headers
text/plain 673b
Update Dmytro's patch. Add utf8 support for output files too. Суб Авг 15 09:58:34 2015, s7078hancock@gmail.com писал: Show quoted text
> Dmytro, > Thanks for the patch, this looks like a better way to go. I changed > the > 'require' to 'use' to get it to work without complaints. When I > tested it > on a file I noticed that the output file was not UTF-8 on my system, > so I > think that the previous coding may need to be retained when the $mode > is > write. > > Any other comments are very welcome. I assume that I will be getting > more > suggestions for improvement once this version starts to get used, so I > will > probably need to do another release fairly soon.
Subject: fix-utf8-output-for-std-and-files.patch
--- Tidy.pm.orig 2015-12-10 15:20:42.236631385 +0500 +++ Tidy.pm 2015-12-10 15:19:01.052440351 +0500 @@ -74,6 +74,7 @@ @EXPORT = qw( &perltidy ); use Cwd; +use Encode (); use IO::File; use File::Basename; use File::Copy; @@ -173,12 +174,6 @@ $fh = $New->( $filename, $mode ) or Warn("Couldn't open file:$filename in mode:$mode : $!\n"); - # The first call here will be to read the config file, which is before - # the --encoding has been set, so the config file cannot be read as utf8 - $fh->binmode(':encoding(utf8)') - if ( $rOpts_character_encoding - && $rOpts_character_encoding eq 'utf8' - && $fh->can('binmode') ); return $fh, ( $ref or $filename ); } @@ -811,12 +806,20 @@ # Prefilters and postfilters: The prefilter is a code reference # that will be applied to the source before tidying, and the # postfilter is a code reference to the result before outputting. - if ($prefilter) { + if ( $prefilter || ( $rOpts_character_encoding && $rOpts_character_encoding eq 'utf8' ) ) { my $buf = ''; while ( my $line = $source_object->get_line() ) { $buf .= $line; } - $buf = $prefilter->($buf); + + $buf = $prefilter->($buf) if $prefilter; + + if ( $rOpts_character_encoding && $rOpts_character_encoding eq 'utf8' && !utf8::is_utf8($buf) ) { + eval { + $buf = Encode::decode('UTF-8', $buf, Encode::FB_CROAK | Encode::LEAVE_SRC); + }; + Die "unable to decode source\n" if $@; + } $source_object = Perl::Tidy::LineSource->new( \$buf, $rOpts, $rpending_logfile_message ); @@ -3935,7 +3938,10 @@ $output_file_open = 1; if ($binmode) { if ( ref($fh) eq 'IO::File' ) { - binmode $fh; + if ( $rOpts->{'character-encoding'} && $rOpts->{'character-encoding'} eq 'utf8' ) { + binmode $fh, ":encoding(UTF-8)"; + } + else { binmode $fh } } if ( $output_file eq '-' ) { binmode STDOUT } }
Download (untitled) / with headers
text/plain 138b
Version 20160301 of perltidy has the latest patch, thanks. I think this issue is closed now but will leave the RT ticket open for a while.
From: qsimpleq
Download (untitled) / with headers
text/plain 199b
Суб Фев 27 12:50:24 2016, SHANCOCK : Show quoted text
> this issue is closed now but will leave the RT ticket open for a > while.
And it was the right decision. -st -utf8 continued to be broken. fixed by patch
Subject: utf8.diff
Download utf8.diff
text/x-diff 1002b
--- Tidy.pm_old 2016-03-01 19:46:22.000000000 +0500 +++ Tidy.pm 2016-04-25 16:04:09.984426450 +0500 @@ -3955,15 +3959,13 @@ unless ($fh) { Perl::Tidy::Die "Cannot write to output stream\n"; } $output_file_open = 1; if ($binmode) { - if ( ref($fh) eq 'IO::File' ) { - if ( $rOpts->{'character-encoding'} - && $rOpts->{'character-encoding'} eq 'utf8' ) + if ( $rOpts->{'character-encoding'} + && $rOpts->{'character-encoding'} eq 'utf8' ) { - binmode $fh, ":encoding(UTF-8)"; + if ( ref($fh) eq 'IO::File' ) { $fh->binmode(":encoding(UTF-8)"); } + elsif ( $output_file eq '-' ) { binmode STDOUT, ":encoding(UTF-8)"; } } - else { binmode $fh } - } - if ( $output_file eq '-' ) { binmode STDOUT } + elsif ( $output_file eq '-' ) { binmode STDOUT } } }
From: qsimpleq
Download (untitled) / with headers
text/plain 199b
Суб Фев 27 12:50:24 2016, SHANCOCK : Show quoted text
> this issue is closed now but will leave the RT ticket open for a > while.
And it was the right decision. -st -utf8 continued to be broken. fixed by patch
Subject: utf8.diff
Download utf8.diff
text/x-diff 1002b
--- Tidy.pm_old 2016-03-01 19:46:22.000000000 +0500 +++ Tidy.pm 2016-04-25 16:04:09.984426450 +0500 @@ -3955,15 +3959,13 @@ unless ($fh) { Perl::Tidy::Die "Cannot write to output stream\n"; } $output_file_open = 1; if ($binmode) { - if ( ref($fh) eq 'IO::File' ) { - if ( $rOpts->{'character-encoding'} - && $rOpts->{'character-encoding'} eq 'utf8' ) + if ( $rOpts->{'character-encoding'} + && $rOpts->{'character-encoding'} eq 'utf8' ) { - binmode $fh, ":encoding(UTF-8)"; + if ( ref($fh) eq 'IO::File' ) { $fh->binmode(":encoding(UTF-8)"); } + elsif ( $output_file eq '-' ) { binmode STDOUT, ":encoding(UTF-8)"; } } - else { binmode $fh } - } - if ( $output_file eq '-' ) { binmode STDOUT } + elsif ( $output_file eq '-' ) { binmode STDOUT } } }
Subject: Re: [rt.cpan.org #32905] Broken handling of UTF-8 strings
Date: Mon, 25 Apr 2016 12:22:01 -0700
To: "bug-Perl-Tidy [...] rt.cpan.org" <bug-Perl-Tidy [...] rt.cpan.org>
From: Steven Hancock <perltidy [...] users.sourceforge.net>
Download (untitled) / with headers
text/plain 1.4k
Thanks for the report and patch. Steve On Mon, Apr 25, 2016 at 4:40 AM, http://mrakobes86reg.id.bk.ru/ via RT < bug-Perl-Tidy@rt.cpan.org> wrote: Show quoted text
> Queue: Perl-Tidy > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=32905 > > > Суб Фев 27 12:50:24 2016, SHANCOCK :
> > this issue is closed now but will leave the RT ticket open for a > > while.
> > And it was the right decision. -st -utf8 continued to be broken. fixed by > patch > > --- Tidy.pm_old 2016-03-01 19:46:22.000000000 +0500 > +++ Tidy.pm 2016-04-25 16:04:09.984426450 +0500 > @@ -3955,15 +3959,13 @@ > unless ($fh) { Perl::Tidy::Die "Cannot write to output stream\n"; > } > $output_file_open = 1; > if ($binmode) { > - if ( ref($fh) eq 'IO::File' ) { > - if ( $rOpts->{'character-encoding'} > - && $rOpts->{'character-encoding'} eq 'utf8' ) > + if ( $rOpts->{'character-encoding'} > + && $rOpts->{'character-encoding'} eq 'utf8' ) > { > - binmode $fh, ":encoding(UTF-8)"; > + if ( ref($fh) eq 'IO::File' ) { > $fh->binmode(":encoding(UTF-8)"); } > + elsif ( $output_file eq '-' ) { binmode STDOUT, > ":encoding(UTF-8)"; } > } > - else { binmode $fh } > - } > - if ( $output_file eq '-' ) { binmode STDOUT } > + elsif ( $output_file eq '-' ) { binmode STDOUT } > } > } > >
This patch is implemented in version 20170521.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.