Re: mod_perl and utf8 and CGI->param

[email protected] (Randal L. Schwartz)
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
>>>>> "Randal" == Randal L Schwartz <[email protected]> writes:

Randal> Yeah, just coded that.  In a BEGIN block in my app, I monkey-patched
Randal> read_from_client:

And then I've also tried to monkey-patch ->read just as you said.

On the first read, an empty string is apparently returned, which fails
something higher in CGI.pm.  Ugh.

Update:

This monkey patch works:

  *Apache2::RequestRec::read = sub {
    warn "READ CALLED";
    goto &$orig;
  }

Although it doesn't do any decoding.  When I replace the body of that
with your code, I'm getting these zero-byte reads.  Even this fails:

    my ($r, $buff, $len, $offset)=@_;
    # my $_buff;
    # my $rc = $r->$orig($_buff, $len);
    my $rc = $r->$orig($buff, $len, $offset);
    # warn "BEFORE: ", DBI::data_string_desc($_buff);
    # utf8::decode($_buff);
    # warn "AFTER: ", DBI::data_string_desc($_buff);
    # substr($buff, $offset, undef, $_buff);
    # warn "AFTER: ", DBI::data_string_desc($buff);
    return $rc;

which should be the same as your code without the utf8 encoding still.
Still getting 0 bytes though.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.