Unfortunately, your API name for your operating system is another “binary interface” where you will need to use Encode::encode and Encode::decode to get predicted results.
Most operating systems treat paths as a sequence of octets (i.e., bytes). Whether this sequence should be interpreted as Latin-1, UTF-8 or another character encoding is the solution of the application. Therefore, the value returned by readdir() is just a sequence of octets, and File::Find does not know that you want the path name to be called Unicode codes. It forms $File::Find::name , simply concatenating the path to the directory (which you specified) with the value returned by your OS via readdir() and how you got the codes broken by octets.
Rule of thumb: Whenever you pass pathnames to the OS, Encode::encode() to make sure this is a sequence of octets. When you get the path name from the OS, Encode::decode() is the character set your application requires.
You can customize your program by calling find as follows:
find( sub { ... }, Encode::encode('utf8', 'Delibes, Léo') );
And then calling Encode::decode() using the value of $File::Find::name :
my $path = Encode::decode('utf8', $File::Find::name);
To be more clear, here is how $File::Find::name :
use Encode;
Erikr source share