Skip Menu |

This queue is for tickets about the JSON CPAN distribution.

Report information
The Basics
Id: 71326
Status: resolved
Priority: 0/
Queue: JSON

People
Owner: Nobody in particular
Requestors: andy [...] halogix.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: JSON clobbers UTF8 flag
Date: Thu, 29 Sep 2011 15:13:20 +1000
To: bug-JSON [...] rt.cpan.org
From: Andrew Wansink <andy [...] halogix.com>
When JSON encoding UTF8 data the resulting JSON string does not have the UTF8 flag set. This is a problem when concatenating the JSON with data which does have the UTF8 flag set, the original UTF8 data ends up being double encoded. #!/usr/bin/perl use strict; use warnings; use JSON; use Encode qw/_utf8_on decode_utf8/; use Devel::Peek; my $foo = { 1 => decode_utf8("Müller") }; Dump($foo->{1}); my $JSON = encode_json($foo); Dump($JSON); my $bar = 'foo '; utf8::upgrade($bar); $bar .= $JSON; Dump($bar);
This code works rightly. 'double encoding' is done by perl itself. Regards,