On Thu Jan 03 19:04:24 2013, vsespb wrote:
Show quoted text> I agree that this is correct behaviour as SHA is defined only for Byte
> Strings.
>
> However I think this should be documented, especially if this behaviour
> is different in different versions (i.e. I can tell that older version
> contain bug - no error message in this case)
>
> test case:
>
> #!/usr/bin/perl
> use utf8;
> use Encode;
> use Digest::SHA qw/sha256_hex/;
> print sha256_hex(encode_utf8('тест'));
> print "\n";
> print sha256_hex('тест');
> print "\n";
>
>
> old version prints two same SHA values.
> new version prints one (same) SHA and dies with warning.
Thanks for supplying a test case. But note that the statement
print sha256_hex('тест');
has no meaning since SHA and other digest algorithms operate on
sequences of bytes, not on Unicode and other wide character data. In
general when invalid data is fed to a program, the output is undefined:
garbage in, garbage out. The fact that the output from invalid data
changes from version to version is of no consequence.
But I do understand your frustration, and therefore may decide to very
briefly warn against wide characters in future versions of the
documentation. If so I'll give you due acknowledgement.
However, such practice is usually not recommended since it clutters the
documentation with extraneous material, distracts the reader, and makes
it more difficult to find information directly pertinent to the module.