in reply to Re: MD5 non ascii file name
in thread MD5 non ascii file name

ok, so if I adopt UTF-16LE would MD5 be able to handle non-ASCII file object?
My intention is to calculate MD5 on a file named '零一.txt'.
$ctx isn't really the problem as this is a code fragment I got from some other places, tested and works, and since there's no 'warning' and 'strict' perl supposed to be lenient about it.
Alas, I fixed 'my $ctx' and '||die on none open'. None are of any issues.
On top of that, File::Find isn't working on a directory named '零一', either, same problem?!?

Replies are listed 'Best First'.
Re^3: MD5 non ascii file name
by moritz (Cardinal) on Aug 19, 2008 at 21:39 UTC
    ok, so if I adopt UTF-16LE would MD5 be able to handle non-ASCII file object?

    Digest and Digest::MD5 can calculate the hash sum of any binary data that you can read in perl.

    And on linux this simply works:

    $ echo foo > 零一.txt
    $ perl -we 'print while <>' 零一.txt
    foo

    (Intentionally no code tags here because they break non-latin1-chars)

    So yes, it's possible, by treating the file names as simple binary data. On Linux, at least ;-).

    On top of that, File::Find isn't working on a directory named '零一', either, same problem?!?

    "not working" is not an error description. What code fails? with what message?

      I will reduce my code for File::Find to a workable fragment before I post, but here are the error msg:
      Use of uninitialized value $file in print at unicodeTest6.pl line 28.
      Use of uninitialized value $file in -f at unicodeTest6.pl line 29.
      invalid top directory at C:/Perl/lib/File/Find.pm line 593.
Re^3: MD5 non ascii file name
by benjwlee (Initiate) on Aug 19, 2008 at 21:38 UTC
    Never mind, you guys are right, I didn't define $ctx.
    Thanks for everybody. Banging head.