Perl's JSON::XS not encoding UTF8 correctly?
问题 This simple code segment shows an issue I am having with JSON::XS encoding in Perl: #!/usr/bin/perl use strict; use warnings; use JSON::XS; use utf8; binmode STDOUT, ":encoding(utf8)"; my (%data); $data{code} = "Gewürztraminer"; print "data{code} = " . $data{code} . "\n"; my $json_text = encode_json \%data; print $json_text . "\n"; The output this yields is: johnnyb@boogie:~/Projects/repos > ./jsontest.pl data{code} = Gewürztraminer {"code":"Gewürztraminer"} Now if I comment out the binmode