[Perl] Trying to write text to a new unicode file (28)

1 Name: #!/usr/bin/anonymous : 2006-09-19 01:51 ID:fr52Zfmu

I'm trying to use a html form and script to write utf8 characters to a utf8 encoded text file. When I copy and paste "⊂二二二( ^ω^)二二二⊃" into the text area, the text file will end up being this: http://sageru.org/stuff/test.txt. If I put the latter into an html file it would show up as the original text, but thats not what I want.

#!/usr/bin/perl
use CGI qw/:standard/;
use Encode;
use utf8;
print header;
if ( param('do') eq "write") {
my $text = param("text");
    print "$text ";
    open(OUT, '>:utf8', "test.txt");
print OUT Encode::encode('utf8', $text);
close(OUT);
    print "done";
}
else {
print "<html><body><form method='post' action='go.pl'><input type='hidden' name='do' value='write'><textarea name='text'>";
print "</textarea><input type='submit'></form></body></html>";
}

I have tried replacing

    Encode::encode('utf8', $text);

with plain old

    $text;

but the result is the same. Can anyone offer help?

This thread has been closed. You cannot post in this thread any longer.