When using Catalyst::Action::REST the content-type response never includes a charset. JSON seems to be handled correctly in code -- JSON strings are always UTF-8. Does that mean there is no need to specify a charset on responses?
And what if a JSON request comes in with a non-UTF8 charset? Should that be ignored? It's application/json, not text/json so maybe there no encoding issues? What about other serializations? YAML is UTF-8 or UTF-16. Does that mean the charset needs to be included in response? And again, if a request comes in with UTF-16 does it need to be decoded or does that happen in YAML::Syck? Event text/html doesn't include a charset in a the "serialized" response. Does there need to be an additional decoding and encoding layer when using Catalyst::Action::REST? Should I force a charset on all responses? BTW -- doesn't seem like YAML survies a round trip like JSON does: As expected: $ perl -MEncode -wle '$x = "\x{263A}"; print length( $x )' 1 $ perl -MEncode -wle '$x = Encode::encode_utf8("\x{263A}"); print length( $x )' 3 And also as expected: $ perl -MJSON -MEncode -wle 'print length(JSON::decode_json(JSON::encode_json( ["\x{263A}"]) )->[0])' 1 But YAML drops the utf8 flag: $ perl -MYAML::Syck -MEncode -wle 'print length(YAML::Syck::Load(YAML::Syck::Dump( ["\x{263A}"]) )->[0])' 3 -- 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/