Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
446 views
in Technique[技术] by (71.8m points)

perl - What is the universal way to use file I/O API with unicode filenames?

In Windows there is a common problem: the filenames should be converted to local codepage, before they are passed to open(). Of course, there is a possibility to use Win32::API for that, but I don't want my script to be platform-dependent. At the moment I have to write something like:

open IN, "<", encode("cp1251", $filename) or die $!; 

but is there any library, that hides these details? I think the local codepage can be automatically detected, so I just want to pass unicode filename and forget about the details. Why is it still not in the box?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It used to just work until 5.8.1, then Jarkko took it out, and broke the -C switch in an gratutious incompatible change on top. This makes Windows a second class citizen and annoys me until today, because any other dynamic language does not have this ridiculous defect. Perhaps now is a good time that we could hear a justification for this change for the worse.

Anyway, you want PerlIO::fse, but it's not a perfect solution, as you will soon discover on your own.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...