title: How to force FastCGI to encode form data as UTF-8 as CGI.pm has option?
body: <p>Trying to run old CGI-scripts under FastCGI. Printing without extra parameters gives proper output: <code>print $q-&gt;div( $q-&gt;param("text") )</code></p>
  
  <p>But when printing out with extra parameters hash for CGI-methods <code>print $q-&gt;div( {-id=&gt;"id"}, $q-&gt;param("text") )</code>, it ruins UTF-8 formed data ('õäöüžš' -> 'ÃµÃ¤Ã¶Ã¼Å¾Å¡')</p>
  
  <p>It happens only with CGI parameters, in script defined variables work fine (examples 3 and 4).  Everything works perfecty under ordinary CGI  (with "-utf8"-flag ).</p>
  
  <p>FastCGI-turned example script, called as <code>test.fcgi?text=õäöüžš</code> should give four equal blocks:</p>
  
  <pre><code>#!/usr/bin/perl -w --
  
  use strict;
  use CGI::Fast qw(:all);
  use locale;
  use utf8;
  
  BEGIN {
          binmode(STDIN);                       # Form data
          binmode(STDOUT, ':encoding(UTF-8)');  # HTML
          binmode(STDERR, ':encoding(UTF-8)');  # Error messages
  }
  
  my ($q) = ();
  my $test = "õäöüžš";
  
  while ($q = new CGI::Fast) {
  
          print $q-&gt;header(-type=&gt;"text/html", -charset=&gt;"utf-8"), 
                  $q-&gt;start_html(-encoding=&gt;"utf-8");
  
          print "1: ",
                  $q-&gt;div(  $q-&gt;param('text') ),
                  "&lt;br /&gt;",
                  "2: ",
                  $q-&gt;div( {-id=&gt;"id"},  $q-&gt;param('text') ),
                  "&lt;br /&gt;",
                  "3: ",
                  $q-&gt;div(  $test ),
                  "&lt;br /&gt;",
                  "4: ",
                  $q-&gt;div( {-id=&gt;"id"},  $test ),
          $q-&gt;end_html();
  
  }
  </code></pre>
  
  <p>First block is fine, second broken, 3rd and 4th also fine:</p>
  
  <p>Ordinary CGI-example as that gives all 4 right way:</p>
  
  <pre><code>#!/usr/bin/perl -w --
  
  use strict;
  use CGI qw(:all -utf8);
  use locale;
  use utf8;
  
  BEGIN {
          binmode(STDIN);                       # Form data
          binmode(STDOUT, ':encoding(UTF-8)');  # HTML
          binmode(STDERR, ':encoding(UTF-8)');  # Error messages
  }
  
  my ($q) = ();
  my $test = "õäöüžš";
  $q = new CGI;
  
          print $q-&gt;header(-type=&gt;"text/html", -charset=&gt;"utf-8"), 
                  $q-&gt;start_html(-encoding=&gt;"utf-8");
  
          print "1: ",
                  $q-&gt;div(  $q-&gt;param('text') ),
                  "&lt;br /&gt;",
                  "2: ",
                  $q-&gt;div( {-id=&gt;"id"},  $q-&gt;param('text') ),
                  "&lt;br /&gt;",
                  "3: ",
                  $q-&gt;div(  $test ),
                  "&lt;br /&gt;",
                  "4: ",
                  $q-&gt;div( {-id=&gt;"id"},  $test ),
          $q-&gt;end_html();
  </code></pre>
  
  <p>It seems to me, that with FastCGI form-data has no utf8-flag on and i don't understand, how to properly force it? Under CGI.pm i declare as:</p>
  
  <pre><code>use CGI qw(:all -utf8);
  </code></pre>
  
  <p>But how with FastCGI? </p>