mod_perl/cgi character encoding issues

Discussion in 'Perl Misc' started by sy crisp, Jul 29, 2005.

  1. sy crisp

    sy crisp Guest

    I have a web page with a textarea into which users can enter text
    including symbols such as á é £.

    When I enter the text 'a á £ $' and submit the form under CGI I get
    'a \xc3\xa1 \xc2\xa3 $' returned via cgi->param.

    Running the same code under mod_perl returns 'a á £ $' which
    looks as though every utf8 byte has been translated into latin1.

    Below is an example script to demonstrate the problem.

    Can anyone tell me what I need to do to stop this double encoding of
    form data under mod_perl?

    Or failing that, how I can convert from 'a á £ $' back to 'a
    \xc3\xa1 \xc2\xa3 $'?

    Thanks,

    Simon

    #!/usr/local/bin/perl -w

    use strict;
    use CGI;

    binmode STDERR;

    my $q = new CGI;
    print $q->header("text/html; charset=utf-8");
    print "<HTML><BODY>\n";

    my $msg = $q->param('AAAA');
    print "<br>AAAA: $msg\n" if $msg;
    print STDERR "AAAA: $msg\n" if $msg;

    print $q->start_form(-method=>'GET');
    print $q->textarea(-name=>'AAAA');
    print $q->submit(-name=>'DOIT');
    print $q->end_form();
    print $q->end_html();
    exit;




    CGI-> AAAA: a \xc3\xa1 \xc2\xa3 $

    MOD_PERL-> AAAA: a á £ $
     
    sy crisp, Jul 29, 2005
    #1
    1. Advertising

  2. sy crisp

    sy crisp Guest

    Some further information that might me useful;


    Apache version 2.0.52 with AddDefaultCharset set to UTF-8

    mod_perl is version 2.0.0

    Perl is version 5.8.6

    CGI.pm is version 3.10
     
    sy crisp, Jul 29, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. raavi
    Replies:
    2
    Views:
    934
    raavi
    Mar 2, 2006
  2. Stefan Fischer
    Replies:
    2
    Views:
    359
    Stefan Fischer
    Feb 23, 2010
  3. David Murray-Rust

    Intermittent Character Encoding Issues

    David Murray-Rust, Nov 4, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    178
    David Murray-Rust
    Nov 7, 2003
  4. David Lee Lambert

    character encoding in CGI.pm

    David Lee Lambert, Nov 24, 2004, in forum: Perl Misc
    Replies:
    14
    Views:
    418
    Matt Garrish
    Nov 27, 2004
  5. Replies:
    2
    Views:
    478
    Big and Blue
    Jan 25, 2006
Loading...

Share This Page