Subject: | fail to comprare utf-8 files |
problem in XML-Diff-0.04 on perl v5.8.4 built for MSWin32-x86-multi-thread
Due to limitation in Digest::MD5 that works only on ascii strings, so the following line fails if $thumbprint contains utf-8 wide characters:
568: $md5_2->add($thumbprint);
To fix it follow the remark about utf-8 in Digest::MD5:
Show quoted text
>What you can do is calculate the MD5 checksum of the UTF-8 >representation of such strings. This is achieved by filtering the string >through encode_utf8() function:
>
> use Digest::MD5 qw(md5_hex);
> use Encode qw(encode_utf8);
>
> my $str = "abc\x{300}";
> print md5_hex(encode_utf8($str)), "\n";
> # 8c2d46911f3f5a326455f0ed7a8ed3b3
So I simply changed the code:
$md5_2->add(encode_utf8($thumbprint));
and added
use Encode qw(encode_utf8);