JohannShunt has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I have a tricky encoding problem on a Catalyst application. The application as a whole is running fine on UTF-8, using the Unicode::Encoding plugin. The only problem is that it also has to deal with a rather archaic 3rd party system for the checkout process, which performs a callback with various parameters in ISO-8859-1, and which is not configurable. If I could get hold of these parameters in my controller I could do some kind of charset conversion, but before I can do anything the application chokes on the callback with a

Caught exception in engine "utf8 "\xA3" does not map to Unicode at /usr/local/share/perl/5.10.1/Catalyst/Plugin/Unicode/Encoding.pm line 145."

Does anyone have any bright ideas on how to skip the Unicode::Encoding plugin's charset validation on parameters for an individual action without actually editing Unicode::Encoding itself, or is that my only option?

Wisdom appreciated in advance.

Replies are listed 'Best First'.
Re: Using alternative encodings for specific Catalyst actions
by Anonymous Monk on Oct 31, 2011 at 14:40 UTC

    Does anyone have any bright ideas on how to skip the Unicode::Encoding plugin's charset validation on parameters for an individual action without actually editing Unicode::Encoding itself, or is that my only option?

    Looking at the source, yes, subclassing is your only option

    Quickest way, override sub _handle_param_unicode_decoding to skip decoding based on some variable (say local $CatMyPlugUnicodeEncoding::DONT=1; )

    The proper way requires more knowledge than I have about moose/catalyst introspection, sub prototypes , etc ... basically, where/how to configure this as a method option

      Thanks for that - I've done as you suggested and subclassed it, and that works fine as a patch for now. Hopefully the callbacks from the 3rd party provider will get more intelligent on encodings. Would be nice if there was a neat way of being a little less strict in Catalyst itself though.