Re: [mp2] utf8 data garbled on second + subsequent loads

[prev] [thread] [next] [Date index for 2005/02/11]

From: Roman =?iso-8859-2?B?VmG57ehlaw==?=
Subject: Re: [mp2] utf8 data garbled on second + subsequent loads
Date: 12:56 on 11 Feb 2005
It is strange. CGI works ok, but i was unable to get correct output even 
from module even first time. It seems to be ok for me after switching 
from perl-script to modperl handler.

apache		2.0.48
mod_perl	1.99_14
perl		5.0.8

<Location /unitest>
        SetHandler modperl
# perl-script does not work - don't know why
#        SetHandler perl-script
        PerlResponseHandler Unitest
</Location>

Here is changed handler and startpage code

sub handler {
  my $r = shift;
  $r->print( header(-type => "text/html",  -charset => "utf-8"));
  $r->print( start_html(
                        # This seems to be no important?
                        -encoding => 'utf-8',
                        -title => "Simple UTF 8 test"));
  $r->print( "\n\n");
  # page calls
  unless (param('VertDo')) {
    $r->print(&startpage());
  }
  $r->print( "\n\n", end_html);
  return Apache::OK;
  #1;
}

sub startpage {
  my %uni = &unihash;
  my $p = '';
  $p = "\n";
  $p .= start_form(-method=>"get", -action=>"/test.html");
  $p .= h1("Unicode test: Page 1");
  $p .= '<table border="1" cellpadding="5">';
  my $tablinedef = "<tr>" . "<td>%s</td>" x 3 . "</tr>\n";
  # Headerline
  $p .= sprintf $tablinedef,
    "description", "language", "char in unicode";
  foreach (sort keys %uni) {
    $p .= sprintf $tablinedef,
      $_ ,
        $uni{$_}->{language},
          textfield(-name=>$_,
                    -default=>$uni{$_}->{character}, -size=>50, -maxlength=>80);
  }
  $p .= '</table>';
  $p .= hidden(-name=>'VertDo',
               -default=>['test unicode']);
  $p .= submit(-name=>'Do',
               -value=>'test unicode');
  $p .= endform;
  return $p;
}

Hope it helps
  Roman

On Fri, Feb 11, 2005 at 11:47:49AM +0000, angie ahl wrote:
> I've looked into it further and stripped it right back to the start.
> 
> Now I just have the unicode chars hard coded in the script and
> printing them to a table.
> 
> I'm not even passing them through a form now, just printing them.
> 
> In CGI mode it works perfectly and in MP2 mode it loads fine the first
> time after apache or the browser is restarted. Then goes kaboom, ie
> gibberish
> 
> Here's both scripts.
[...]

        -- 
         best regards
  Ing. Roman Vasicek

 software developer
+----------------------------------------------------------------------------+
 PetaMem s.r.o., Ocelarska 1, 190 00 Praha 9 - Liben, Czech Republic
 http://www.petamem.com/

Re: [mp2] utf8 data garbled on second + subsequent loads
Roman =?iso-8859-2?B?VmG57ehlaw==?= 07:48 on 11 Feb 2005

Re: [mp2] utf8 data garbled on second + subsequent loads
Roman =?iso-8859-2?B?VmG57ehlaw==?= 12:56 on 11 Feb 2005

Re: [mp2] utf8 data garbled on second + subsequent loads
Roman =?iso-8859-2?B?VmG57ehlaw==?= 16:10 on 11 Feb 2005

Generated at 11:21 on 20 Feb 2005 by mariachi v0.52