in reply to help needed in opendir

is it possible to open directory handle with utf8 format?

I think the answer is "No, not really, natively." I base this (possibly wrong) conclusion on the following paragraph, found in perlunicode:

When Unicode Does Not Happen

While Perl does have extensive ways to input and output in Unicode, and few other 'entry points' like the @ARGV which can be interpreted as Unicode (UTF-8), there still are many places where Unicode (in some encoding or another) could be given as arguments or received as results, or both, but it is not.

The following are such interfaces. For all of these interfaces Perl currently (as of 5.8.3) simply assumes byte strings both as arguments and results, or UTF-8 strings if the encoding pragma has been used.

One reason why Perl does not attempt to resolve the role of Unicode in this cases is that the answers are highly dependent on the operating system and the file system(s). For example, whether filenames can be in Unicode, and in exactly what kind of encoding, is not exactly a portable concept. Similarly for the qx and system: how well will the 'command line interface' (and which of them?) handle Unicode?

  • chdir, chmod, chown, chroot, exec, link, lstat, mkdir, rename, rmdir, stat, symlink, truncate, unlink, utime, -X
  • %ENV
  • glob (aka the <*>)
  • open, opendir, sysopen
  • qx (aka the backtick operator), system
  • readdir, readlink

Addition:

See also Perl's documentation for the 'open' pragma. This pragma allows you to set default layers for input and output (ie, character encoding support for IO). There is one sentence which is telling:

Directory handles may also support PerlIO layers in the future.

...which means, that at least as of 5.8.8, directory handles do not support PerlIO layers.


Dave