File-Find-utf8
view release on metacpan or search on metacpan
$File::Find::utf8::SPECIALVARS
By default File::Find::utf8 only decodes the normal File::Find
variables $_, $File::Find::name, $File::Find::dir, and (when follow or
follow_fast is in effect) $File::Find::fullname for use in the
preprocess, wanted, and postporcess functions.
If for any reason (e.g., compatibility with find.pl or find2perl) you
also need the special variables $File::Find::topdir,
$File::Find::topdev, $File::Find::topino, $File::Find::topmode, and
$File::Find::topnlink to be decoded, specify local
$File::Find::utf8::COMPATILBILITY = 1; in your code. The extra decoding
that needs to happen will impact performance though, so use only when
absolutely necessary.
$File::Find::utf8::UTF8_CHECK
By default File::Find::utf8 marks decoding errors as fatal (default
value for this setting is Encode::FB_CROAK). If you want, you can
change this by setting File::Find::utf8::UTF8_CHECK. The value
Encode::FB_WARN reports the encoding errors as warnings, and
README.mkdn view on Meta::CPAN
By default `File::Find::utf8` only decodes the _normal_
[File::Find](https://metacpan.org/pod/File%3A%3AFind) variables `$_`, `$File::Find::name`,
`$File::Find::dir`, and (when `follow` or `follow_fast` is in
effect) `$File::Find::fullname` for use in the `preprocess`,
`wanted`, and `postporcess` functions.
If for any reason (e.g., compatibility with find.pl or find2perl) you
also need the _special_ variables `$File::Find::topdir`,
`$File::Find::topdev`, `$File::Find::topino`,
`$File::Find::topmode`, and `$File::Find::topnlink` to be decoded,
specify `local $File::Find::utf8::COMPATILBILITY = 1;` in your
code. The extra decoding that needs to happen will impact performance
though, so use only when absolutely necessary.
## $File::Find::utf8::UTF8\_CHECK
By default `File::Find::utf8` marks decoding errors as fatal (default value
for this setting is `Encode::FB_CROAK`). If you want, you can change this by
setting `File::Find::utf8::UTF8_CHECK`. The value `Encode::FB_WARN` reports
the encoding errors as warnings, and `Encode::FB_DEFAULT` will completely
lib/File/Find/utf8.pm view on Meta::CPAN
#pod
#pod By default C<File::Find::utf8> only decodes the I<normal>
#pod L<File::Find> variables C<$_>, C<$File::Find::name>,
#pod C<$File::Find::dir>, and (when C<follow> or C<follow_fast> is in
#pod effect) C<$File::Find::fullname> for use in the C<preprocess>,
#pod C<wanted>, and C<postporcess> functions.
#pod
#pod If for any reason (e.g., compatibility with find.pl or find2perl) you
#pod also need the I<special> variables C<$File::Find::topdir>,
#pod C<$File::Find::topdev>, C<$File::Find::topino>,
#pod C<$File::Find::topmode>, and C<$File::Find::topnlink> to be decoded,
#pod specify C<local $File::Find::utf8::COMPATILBILITY = 1;> in your
#pod code. The extra decoding that needs to happen will impact performance
#pod though, so use only when absolutely necessary.
#pod
#pod =cut
our $SPECIALVARS = 0;
#pod =attr $File::Find::utf8::UTF8_CHECK
#pod
lib/File/Find/utf8.pm view on Meta::CPAN
By default C<File::Find::utf8> only decodes the I<normal>
L<File::Find> variables C<$_>, C<$File::Find::name>,
C<$File::Find::dir>, and (when C<follow> or C<follow_fast> is in
effect) C<$File::Find::fullname> for use in the C<preprocess>,
C<wanted>, and C<postporcess> functions.
If for any reason (e.g., compatibility with find.pl or find2perl) you
also need the I<special> variables C<$File::Find::topdir>,
C<$File::Find::topdev>, C<$File::Find::topino>,
C<$File::Find::topmode>, and C<$File::Find::topnlink> to be decoded,
specify C<local $File::Find::utf8::COMPATILBILITY = 1;> in your
code. The extra decoding that needs to happen will impact performance
though, so use only when absolutely necessary.
=head2 $File::Find::utf8::UTF8_CHECK
By default C<File::Find::utf8> marks decoding errors as fatal (default value
for this setting is C<Encode::FB_CROAK>). If you want, you can change this by
setting C<File::Find::utf8::UTF8_CHECK>. The value C<Encode::FB_WARN> reports
the encoding errors as warnings, and C<Encode::FB_DEFAULT> will completely
# Expected output of find commands
my @expected = sort ($test_root, "$test_root/$unicode_dir", "$test_root/$unicode_dir/bar", "$test_root/$unicode_file");
# Check utf8 and non-utf8 results
sub check_results {
my ($test, $utf8, $non_utf8) = @_;
my @utf8 = sort @{$utf8}; # Sort to overcome difference in find and finddepth
my @non_utf8 = sort @{$non_utf8}; # Sort to overcome difference in find and finddepth
my @utf8_encoded = map { encode_utf8($_); } @utf8;
my @non_utf8_decoded = map { decode_utf8($_, FB_CROAK | LEAVE_SRC); } @non_utf8; # Quotes to prevent tampering by encode/decode!
plan tests => 3;
is_deeply \@utf8, \@expected, "$test all utf8 files are present";
is_deeply \@utf8, \@non_utf8_decoded, "$test utf8 files match decoded non-utf8";
is_deeply \@utf8_encoded, \@non_utf8, "$test encoded utf8 files match non-utf8";
}
plan tests => 3;
# Check find and finddepth
for my $test (qw(find finddepth)) {
subtest "utf8$test" => sub {
# To keep results in
my @utf8;
( run in 0.689 second using v1.01-cache-2.11-cpan-26ccb49234f )