title: Perl's JSON::XS not encoding UTF8 correctly?
body: <p>This simple code segment shows an issue I am having with JSON::XS encoding in Perl:</p>
  
  <pre><code>#!/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";
  </code></pre>
  
  <p>The output this yields is:</p>
  
  <pre><code>johnnyb@boogie:~/Projects/repos &gt; ./jsontest.pl 
  data{code} = Gewürztraminer
  {"code":"GewÃ¼rztraminer"}
  </code></pre>
  
  <p>Now if I comment out the binmode line above I get:</p>
  
  <pre><code>johnnyb@boogie:~/Projects/repos &gt; ./jsontest.pl 
  data{code} = Gew�rztraminer
  {"code":"Gewürztraminer"}
  </code></pre>
  
  <p>What is happening here? Note that I am trying to fix this behavior in a perl CGI script in which binmode can not be used but I always get the "Ã¼" characters as above returned in the JSON stream. How do I debug this? What am I missing? </p>