http://www.perlmonks.org?node_id=916353


in reply to Re: JSON, UTF-8 and Filehandles
in thread JSON, UTF-8 and Filehandles

Aha, thanks.

I went and took a second look at the JSON manpage too.. apparently the utf8 option in JSON already takes the liberty of encoding the output (removing the UTF-8 flag in Perl, making it render as garbage), which is good if you're using JSON.pm to send/receive data over a network socket. Without the utf8 option, JSON still "supports" UTF-8, it just doesn't automatically do the string encoding/decoding.

I find it a little bit weird that, if you don't use utf8;, and open a filehandle in UTF-8 mode, that wide characters printed to it are mangled; is this because Perl doesn't expect Unicode to be written to the filehandle (because the script printing it didn't use utf8), so it double-encodes it?