I just finally removed my custom encoding code to use the built-in code Catalyst now provides to decode input data and encode output.
But, I came across two issues that I wanted to get some feedback on. First one is simple. This code will die if $value is already decoded. Any reason not to test it? sub _handle_param_unicode_decoding { my ( $self, $value, $check ) = @_; return unless defined $value; # not in love with just ignoring undefs - jnap return $value if blessed($value); #don't decode when the value is an object. + return $value if Encode::is_utf8($value); # already decoded? This next one is what I have questions about. This is also in Catalyst.pm in the encoding() method: # Let it be set to undef if (my $wanted = shift) { $encoding = Encode::find_encoding($wanted) or Carp::croak( qq/Unknown encoding '$wanted'/ ); *binmode(STDERR, ':encoding(' . $encoding->name . ')');* The problem with that is it seems to turn off autoflush on STDERR. In my case that is causing intermixing of lines in the log files. If I turn on STDERR->autoflush(1) then the logging works again and log lines are not mangled. But, I'm not sure we should apply a layer to STDERR like that. For example, I log to stderr with JSON and that is already encoded. Is there a compelling reason to binmode STDERR there? -- Bill Moseley mose...@hank.org
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/