Given that you are using perl's readdir, and you are getting some sort of string as a result, you might want to try a little test script to show the actual byte values that are being used in the file names. Something like this would do -- and while we're at it, let's check to see if the string returned by readdir can actually be used to get information about the file and open it:
#!/usr/bin/perl use strict; use warnings; (@ARGV == 1 and -d $ARGV[0]) or die "Usage: $0 pathname\n"; my $dir = shift; opendir( DIR, $dir ) or die "$dir: $!"; while ( $_ = readdir DIR ) { next if ( /^\.\.?$/ ); print join( " ", map { sprintf( " %02x", ord($_)) } split //, $_ ) +; if ( -f ) { open( I, $_ ) or do { warn "$_: $!"; next }; my $sum = 0; $sum += length() while (<I>); close I; printf( " : %d bytes (%d read)\n", -s _, $sum ); } elsif ( -d _ ) { print " : directory\n"; } else { print " : not sure what this is\n" } }
If you don't know how to use the information that comes out of that, post a reply with a few examples of the output for non-ASCII file names (look for lines containing hex numerics greater than " 7f ").

You might also want to take a bunch of these odd-ball file names (as fetched by readdir) and concatenate them (with spaces between them) into a single long string, and pass that to the "guess_encoding" function provided by Encode::Guess -- if the characters really are non-unicode Asian or some form of unicode, there's a good chance it'll give you a correct answer, which you can then use with Encode's "decode" function, to turn the strings into perl-internal utf8 (in case that's helpful for anything).


In reply to Re: Opening files with japanese/chinese chars in filename by graff
in thread Opening files with japanese/chinese chars in filename by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.