perl-unicode

Re: MD5 digest of UTF-8 string in Perl 5.8

2002-10-23 08:30:08
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 23 October 2002 17:20, Markus Kuhn wrote:
How can I calculate the MD5 message digest of a Unicode string in
Perl 5.8? The MD5 hash algorithm naturally expects a sequence of
bytes as its input, and I have a string with a sequence of
characters. I tried

  $ perl -e 'use Digest::MD5 qw(md5_hex); print md5_hex("\x{20ac}");'
  Wide character in subroutine entry at -e line 1.

The problem is in \x{20ac}. If you place the character in UTF-8 encoding 
in place of the escape, it works perfectly. If you have real UTF-8 
data, not perl escapes, then there is no problem.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9trVcnksV4Ys/z5gRAnmeAKCN1lpz3PsCkqbmrXHWs/9YvB83BACdFkyl
yiJ292C259r7zPBxUNw+KkI=
=4wSg
-----END PGP SIGNATURE-----

<Prev in Thread] Current Thread [Next in Thread>