Should perl's File::Glob always be post-filtered through utf8::decode?

匿名 (未验证) 提交于 2019-12-03 08:48:34

问题:

The output of the following minimal example shows that (on my linux machine) File::Glob seems to have the unexpected side-effect of converting a utf8 string to non-utf8:

This is causing wrong behavior in my program. On linux, it looks like I can fix it by applying utf8::decode() after File::Glob. Is this the right way to fix this? Is this a bug in File::Glob? Will my fix produce correct results on other systems such as Windows?

回答1:

Encoding handling of functions dealing with file names is currently on perl's todo list: Unicode in Filenames. Problem is that some popular operating systems (i.e. Linux) don't have support for file name encoding (other than using the current locale settings, but this is broken by design), so getting a portable solution in Perl is not that easy.

My advice is to avoid non-ASCII file names at all.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!