perl-unicode

Re: perlunicode comment - when Unicode does not happen

2003-12-22 18:30:07

On Mon, 22 Dec 2003 14:31:15 -0500
"Ed Batutis" <ed(_at_)batutis(_dot_)com> wrote:

$newdir = "kanji_here_\x89\x5C";
mkdir $newdir;

The above works the way I'd expect, although

print (-d $newdir ? 'yes' : 'no');

prints 'no' - oops a character handling bug! The second byte of the kanji is
a backslash, which confuses Perl, apparently. "-d" really ought to assume
the user knows what he is doing and do character-handling based on the
current file system encoding setting (LC_CTYPE or the equivalent).

Try this.

    print (-d "$newdir\\" ? 'yes' : 'no');

I had talked on this "problem" (well, I don't know whether Perl
supports multibyte file/path names or not.) in a Japanese Perlers'
mail list.

http://www.freeml.com/message/perl(_at_)freeml(_dot_)com/0004467 (in Japanese)

Here is a brief summary (in Japanese).

http://homepage1.nifty.com/nomenclator/perl/shiftjis.htm#file

Regards,
SADAHIRO Tomoyuki