title: Perl and HTML: UTF8 does not work in forms
body: <p>I tried to change my Perl / HTML files to the UTF-8 format. Unfortunately I have a problem with forms. I created a little test script which exemplifies the problem. All it does is reload itself, so that the text entered will be shown again. It works fine with ASCII characters. As soon as I enter German "Umlaute" (ÄÖÜ) the characters get distorted. It cannot handle russian characters (ЭЯЮ) as well. Here is the script:</p>
  
  <pre><code>#!/usr/bin/perl
  
  use utf8;
  use Encode;
  use open ':std', ':encoding(UTF-8)';
  
  # Safe query-string in hash:
  $querystring = $ENV{ 'QUERY_STRING' };
  read(STDIN, $poststring, $ENV{CONTENT_LENGTH});
  if (($querystring ne "") &amp;&amp; ($poststring ne "")) { $querystring .= "&amp;$poststring"; } 
      else { $querystring .= $poststring; }
  
  $querystring =~ s/&amp;/=/gi;
  %query = split( /=/, $querystring );
  foreach $key ( keys( %query ) ) {
      $query{$key} =~ tr/+/ /;
      $query{$key} =~ s/%([\da-f][\da-f])/chr( hex($1) )/egi;
      $uquer{$key} = decode_utf8( $query{$key} );
  }
  
  print "Content-Type: text/html; charset=\"UTF-8\"\n\n";
  print &lt;&lt;END;
      &lt;HTML&gt;
          &lt;HEAD&gt;
              &lt;META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8"&gt;
          &lt;/HEAD&gt;
          &lt;BODY&gt;
              &lt;FORM NAME="frmeing" METHOD="POST" ACTION="test0.cgi"&gt;
                  &lt;INPUT NAME="df_kurs" TYPE="TEXT" VALUE="$uquer{'df_kurs'}"&gt;
                  &lt;INPUT TYPE="SUBMIT"&gt;
              &lt;/FORM&gt;
          &lt;/BODY&gt;
      &lt;/HTML&gt;
  END
  </code></pre>
  
  <p>You can test this script as well. It is online at this address:
  <a href="http://project-website.org/test/test0.cgi" rel="nofollow">http://project-website.org/test/test0.cgi</a>
  Does anybody know what could be the problem? Thank you in advance for your help!</p>