Can the File :: Find :: Rule file be fixed to automatically handle encoding / decoding of the file name?

Suppose I have a file named æ(UNICODE: 0xE6, UTF8: 0xC3 0xA6) in the current directory.

Then I would use File::Find::Ruleto find it:

use feature qw(say);
use open qw( :std :utf8 );
use strict;
use utf8;
use warnings;

use File::Find::Rule;

my $fn = 'æ';
my @files = File::Find::Rule->new->name($fn)->in('.');
say $_ for @files;

The output is empty, so apparently this did not work.

If I try to encode the file name first:

use Encode;

my $fn = 'æ';
my $fn_utf8 = Encode::encode('UTF-8', $fn, Encode::FB_CROAK | Encode::LEAVE_SRC);
my @files = File::Find::Rule->new->name($fn_utf8)->in('.');
say $_ for @files;

Output:

æ

So he found the file, but the returned file name is not decoded into the Perl string. To fix this, I can decode the result by replacing the last line:

say Encode::decode('UTF-8', $_, Encode::FB_CROAK) for @files;
Question: if both encoding and decoding could / should have been done automatically with File::Find::Rule, so I could use my original program and not have to worry about encoding and decoding at all?

(, File::Find::Rule I18N::Langinfo, , UTF-8??)

+2
1

, . Perl, , .

, , , , . , , , . , Python .

.

+2

All Articles