P is for Practical | |
PerlMonks |
Re: Catalyst: Wide character outside byte range in response. Encoding data as UTF-8by sundialsvc4 (Abbot) |
on Dec 31, 2014 at 17:00 UTC ( [id://1111848]=note: print w/replies, xml ) | Need Help?? |
If you called decode() on $content before passing it to the template, then, yes, you would “cause the message to go away.” But you have altered the content possibly in a destructive way as-seen by a Chinese user (but perhaps, not as-seen by non-Chinese you). What you probably want to do is to explicitly encode() the string before passing it to the template, thereby relieving the ever-vigilant Catalyst from having to do this for you. If the string contains no UTF characters, encoding will do nothing to the content. If it does, it will do the right thing to it. decoding would be applied to incoming data, not outgoing data. (And if I have this backwards, you’ll see my mistake being pointed-out by snarky replies and downvotes within a matter of minutes if not seconds ...) I am not familiar with that plug-in, but what I would do is to look at the source-code of it. (Who knows, maybe that plug-in is what is actually producing the message?) Anyhow, I prefer not to rely upon plug-ins to do such things. I prefer to have full and conscious control of when and how every encoding/decoding step is done, because plug-ins necessarily have to “guess.”
In Section
Seekers of Perl Wisdom
|
|