[mplspm]: Unicode help
Mark Allen
mark.allen at shavlik.com
Thu Mar 25 17:43:04 CST 2004
Anyone use Unicode much?
Maybe someone can help me figure out why this isn't working the way I
expect?
--
#!/usr/bin/perl
use strict;
use warnings;
use Encode;
my $text="Convert me to Unicode!";
open ASCII, ">text.ascii";
print ASCII $text;
close ASCII;
my $ttext=Encode::encode_utf8($text); # Convert perl internal byte order
to UTF8
open UTF, ">:utf8", "text.utf8"; # Perl 5.8ism, use file
discipline^Wlayer
print UTF $ttext;
close UTF;
--
% md5sum text.*
9a08eca1cbab4f1c12bf4f771baad063 text.ascii
9a08eca1cbab4f1c12bf4f771baad063 text.utf8
I'm expecting the Unicode string to be (as represented by a C array)
string[] = { 'C', 0, 'o', 0, 'n', 0 ... };
So the UTF8 file ought to be twice as big as the ASCII file and have a
totally different MD5 hash. What am I missing?
Thanks!
--Mark
--------------------------------------------------
Minneapolis Perl Mongers mailing list
To unsubscribe, send mail to majordomo at pm.org
with "unsubscribe mpls" in the body of the message.
More information about the Mpls-pm
mailing list