#!/usr/local/perl5.6.1/bin/perl
require "httpd-paths.ph" || die "$0: can't load httpd-paths.ph: $!\n";
use XML::Simple;
use CGI;
use CGI::Carp;
use utf8;

my $file = \*DATA;
my $xmlSimple = XML::Simple->new(searchpath => ".", forcearray => 0,parseropts => [ProtocolEncoding => 'UTF-8']);
my $xml = $xmlSimple->XMLin($file);

my $q = new CGI;

print "Content-type: text/html; charset=utf-8\n\n";

print <<END;
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
</head>
<body>
END

print <<END;
<form action="/cgi-bin/testUTF8.pl" method="post" enctype="multipart/form-data">
<textarea name="text" style="width:400;height:200">
END

$text = $q->param('text');
if ($q->param('text')) {
  my $out = '';
  $out .= $xml->{message};
  $out .= " ";
  $out .= $text;
  $out .= "\n";
  print $out;
  print $text;
}

print <<END;
</textarea>
<form>
<br>
<input type="submit"><br><br>
END


foreach $i (keys %ENV) {
 print "$i:$ENV{$i} <br>\n";
}

print <<END;
</body>
</html>
END


__DATA__
<?xml version="1.0" encoding="UTF-8"?>
<buzz>
  <message>hello</message>
</buzz>