develooper Front page | perl.perl5.porters | Postings from June 2008

[rt.cpan.org #36817] Incomplete documentation of CGI::charset

From:
Crawford Currie via RT
Date:
June 17, 2008 06:57
Subject:
[rt.cpan.org #36817] Incomplete documentation of CGI::charset
Message ID:
rt-3.6.HEAD-10786-1213710976-409.36817-4-0@rt.cpan.org
Tue Jun 17 09:56:16 2008: Request 36817 was acted upon.
Transaction: Ticket created by CDOT
       Queue: CGI.pm
     Subject: Incomplete documentation of CGI::charset
   Broken in: 3.29
    Severity: Normal
       Owner: Nobody
  Requestors: cpan@c-dot.co.uk
      Status: new
 Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=36817 >


Trap for the unwary.

When CGI::charset is called from a query object (e.g. $query->charset)
then there is an undocumented side effect; the encoding of text
parameters changes. For example, if you do this:

use CGI;
my $query = new CGI({ text => [ Encode::encode_utf8(chr(8192)) ]});
CGI::charset('utf-8');
print $query->param('text');

then you will get a UTF8-encoded byte string printed. If however you call

$query->charset('utf-8');

instead of CGI::charset you will get a unicode string instead, resulting
in a 'Wide character in print' error.

This behaviour is acceptable, but needs to be documented in the man page.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About