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.

_______ START CGI SCRIPT _______

#!/usr/local/bin/perl
#
#       Author Angie Ahl ([EMAIL PROTECTED]) : 2004/12/01 22:14:00
#
# script to test unicode, standard cgi mode.
# requires perl 5.8, DBI, DBD::MySQL, CGI and Encode

use strict;
use warnings;
use 5.008006;

use utf8;
use DBI;
use CGI (':standard');
use Encode qw/is_utf8 decode/;

binmode(STDOUT, ":utf8");

                        print header(-type => "text/html",  -charset
=> "utf-8");
                        print start_html(
                                        # This seems to be no important?
                                         -encoding => 'utf-8',
                                        -title => "Simple UTF 8 test");
                        print "\n\n";

# page calls
        unless (param('VertDo')) {
                        &startpage;
        }

        print "\n\n", end_html;

sub startpage {
        my %uni = &unihash;

        print "\n";
        print start_form(-method=>"get", -action=>"/test.html");
        print h1("Unicode test: Page 1");
        print '<table border="1" cellpadding="5">';

        my $tablinedef = "<tr>" . "<td>%s</td>" x 3 . "</td>\n";
        # Headerline
        printf $tablinedef,
                        "description","language","char in unicode";

        foreach (sort keys %uni) {
                        printf $tablinedef,
                        $_,
                        $uni{$_}->{language},
                        textfield(-name=>$_,
-default=>$uni{$_}->{character}, -size=>50, -maxlength=>80);
        }
        print '</table>';
        print hidden(-name=>'VertDo',
                             -default=>['test unicode']);

        print submit(-name=>'Do',
                        -value=>'test unicode');
        print endform;

}

# subroutines

sub unihash {
        my %uni = (
                        hebrew_alef => {
                                        character => chr(0x05d0),
                                        language => "hebrew",
                        },
                        smiley => {
                                        character => "\x{263a}",
                                        language => "none",
                        },
                        zcaron => {
                                        character => "\x{017d}",
                                        language => "czech",
                        },
                        aogonec => {
                                        character => "\x{0104}",
                                        language => "polish",
                        },
                        lslash => {
                                        character => "\x{0142}",
                                        language => "polish",
                        },
                        recenu => {
                                        character => "re\x{e7}enu",
                                        language => "french",
                        },
                        citroen => {
                                        character => "citro\x{eb}n",
                                        language => "french",
                        },
                        abimer => {
                                        character => "ab\x{ee}mer",
                                        language => "french",
                        },
                        disco => {
                                        character => "discoth\x{e8}que",
                                        language => "french",
                        },
                        angies => {
                                        character =>
"\x{0142}\x{e7}\x{263a}\x{0104}\x{263a}\x{0104}re\x{e7}enu\x{263a}",
                                        language => "mixed",
                        },
        );
return %uni;
}

_______ END CGI SCRIPT _______

_______ START MP2 PACKAGE _______

package unitest;

#!/usr/local/bin/perl
#
#       Author Angie Ahl ([EMAIL PROTECTED]) : 2004/12/01 22:14:00
#
# script to test unicode, standard cgi mode.
# requires perl 5.8, DBI, DBD::MySQL, CGI and Encode

use strict;
use warnings;
use 5.008006;

use utf8;
use DBI;
use CGI (':standard');
use Encode qw/is_utf8 decode/;

binmode(STDOUT, ":utf8");

sub handler {

                        print header(-type => "text/html",  -charset
=> "utf-8");
                        print start_html(
                                        # This seems to be no important?
                                         -encoding => 'utf-8',
                                        -title => "Simple UTF 8 test");
                        print "\n\n";

# page calls
        unless (param('VertDo')) {
                        &startpage;
        }

        print "\n\n", end_html;

        return Apache::OK;
        #1;
}

sub startpage {
        my %uni = &unihash;

        print "\n";
        print start_form(-method=>"get", -action=>"/test.html");
        print h1("Unicode test: Page 1");
        print '<table border="1" cellpadding="5">';

        my $tablinedef = "<tr>" . "<td>%s</td>" x 3 . "</td>\n";
        # Headerline
        printf $tablinedef,
                        "description","language","char in unicode";

        foreach (sort keys %uni) {
                        printf $tablinedef,
                        $_,
                        $uni{$_}->{language},
                        textfield(-name=>$_,
-default=>$uni{$_}->{character}, -size=>50, -maxlength=>80);
        }
        print '</table>';
        print hidden(-name=>'VertDo',
                             -default=>['test unicode']);

        print submit(-name=>'Do',
                        -value=>'test unicode');
        print endform;

}

# subroutines

sub unihash {
        my %uni = (
                        hebrew_alef => {
                                        character => chr(0x05d0),
                                        language => "hebrew",
                        },
                        smiley => {
                                        character => "\x{263a}",
                                        language => "none",
                        },
                        zcaron => {
                                        character => "\x{017d}",
                                        language => "czech",
                        },
                        aogonec => {
                                        character => "\x{0104}",
                                        language => "polish",
                        },
                        lslash => {
                                        character => "\x{0142}",
                                        language => "polish",
                        },
                        recenu => {
                                        character => "re\x{e7}enu",
                                        language => "french",
                        },
                        citroen => {
                                        character => "citro\x{eb}n",
                                        language => "french",
                        },
                        abimer => {
                                        character => "ab\x{ee}mer",
                                        language => "french",
                        },
                        disco => {
                                        character => "discoth\x{e8}que",
                                        language => "french",
                        },
                        angies => {
                                        character =>
"\x{0142}\x{e7}\x{263a}\x{0104}\x{263a}\x{0104}re\x{e7}enu\x{263a}",
                                        language => "mixed",
                        },
        );
return %uni;
}

_______ END MP2 PACKAGE _______

Reply via email to