in reply to utf8::downgrade() and file system operators

I'm not a subject matter expert on this and I'm going from my memory, so I apologize for using incorrect terminology or other unintentional inaccuracies.

Windows has two different APIs for the filesystem. The default API that most programs use (including Perl) has a limitation of about 255 character length on paths and does not support Unicode characters. The other API supports both longer paths and Unicode characters.

Although it sounds like you found a work around that appears to work with the paths that you tested, I personally would be concerned that there could be some situations (or corner cases) where that might not work. If you want to leverage the alternate filesystem API, you can take a look at Win32::LongPath, which "provides replacement functions for most of the native Perl file functions". From your post, you mention stat and file test operators. The Win32::LongPath alternates are statL and testL.

I'll refrain from commenting on what should or should not be recommended to Perl porters on this topic because I don't think I understand things enough to speak intelligently on the topic.

  • Comment on Re: utf8::downgrade() and file system operators

Replies are listed 'Best First'.
Re^2: utf8::downgrade() and file system operators
by hexcoder (Curate) on Feb 17, 2024 at 11:49 UTC
    Thanks for bringing that second API to my attention!

    I agree that utf8::downgrade() is not a general solution, because it depends on the characters being mappable. They are in my use cases for now.

    I am interested in a more general solution without sacrificing portability, but if everything else fails, it is good to know that such a way out exists.