Data-AnyXfer

 view release on metacpan or  search on metacpan

t/json/upstream/01_utf8.t  view on Meta::CPAN


SKIP: {
  skip "5.6", 1 if $] < 5.008;
  require Encode;
  # [RT #84244] wrong complaint: JSON::XS double encodes to ["I ❤ perl"]
  #             and with utf8 triple encodes it to ["I ❤ perl"]
  if ($Encode::VERSION < 2.40 || $Encode::VERSION >= 2.54) { # Encode stricter check: Cannot decode string with wide characters
    # see also http://stackoverflow.com/questions/12994100/perl-encode-pm-cannot-decode-string-with-wide-character
    $love = "I \342\235\244 perl";
  }
  my $s = Encode::decode_utf8($love); # User tries to double decode wide-char to unicode with Encode
  is(Data::AnyXfer::JSON->new->utf8->encode ([$s]), "[\"I \342\235\244 perl\"]", 'utf8 enc utf8 [RT #84244]');
}
is(Data::AnyXfer::JSON->new->binary->encode ([$love]), '["I \xe2\x9d\xa4 perl"]', 'utf8 enc binary');



( run in 0.504 second using v1.01-cache-2.11-cpan-88abd93f124 )