Subject: | Incomplete documentation of CGI::charset |
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.