On Sun, Feb 20, 2022 at 01:09:06PM +0000, Gavin Smith wrote: > On Sun, Feb 20, 2022 at 01:45:19PM +0100, Patrice Dumas wrote: > > On Sun, Feb 20, 2022 at 01:10:16PM +0100, Patrice Dumas wrote: > > > > > > I think that the correct way to do that is to use > > > Encode::encode($text, 'utf-8'); > > > Also I think that it should be done as late as possible, so it would be > > > better on $possible_file. > > My thought was that the argument to -I could have been any sequence of bytes, > not necessarily correct UTF-8. It would be wrong then to attempt any > encoding or decoding to a string formed from such an argument.
Indeed, that must be what is happening here. I think that it is not necessarily wrong to do decoding. Actually, if the locale is not consistent with the encoding expected for file names, it would be even better to first decode command line arguments to the perl internal unicode encoding, then encode to the encoding that should work for operations using filenames. That is the solution that I would favor. -- Pat
