Subject: | utf8 flag is randomly maintained in autoactions on v5.20+ |
package G;
use Regexp::Grammars;
my $parser = qr{
<TOP>
<rule: TOP>.*
}xms;
sub interpret {
my ($text, $actions) = @_;
$parser->with_actions( $actions );
return $text ~~ $parser;
}
package A;
use Encode;
use Mouse;
sub TOP {
my ($self, $match) = @_;
printf "TOP autoaction, match=%s is_utf8=%s\n", $match, Encode::is_utf8($match);
return $match;
}
package main;
use utf8;
G::interpret( 'zażółć gęślą jaźń', A->new); # some polish text
G::interpret( 'שלום העולם', A->new); # some RTL text
__END__
On Perl 5.20.1 and 5.21.5 it gives following result:
---
TOP autoaction, match=zażółć gęślą jaźń is_utf8=
TOP autoaction, match=שלום העולם is_utf8=1
---
Flag utf8 is lost for first unicode string but preserved for second. Both are expected to have it.