I use some XS modules that expect latin1 string data (and ignore the Perl UTF8 flag). In some cases, I pass the result of JSON decoding, which should include only Latin characters, but in some cases they are escaped (for example, ["co\u00f6perative"] ).
Is there a JSON decoding module that offers the ability to return lines down (at least when possible)? I do not find such an option in JSON, JSON :: XS or Cpanel :: JSON :: XS.
use strict; use warnings; use Cpanel::JSON::XS; use Devel::Peek; my $got = Cpanel::JSON::XS->new->decode('["co\u00f6perative"]')->[0]; Dump $got; my $wanted = $got; utf8::downgrade($wanted); Dump $wanted;
output:
SV = PV(0xd6cbf0) at 0xd8a460 REFCNT = 1 FLAGS = (POK,IsCOW,pPOK,UTF8) PV = 0xd83b40 "co\303\266perative"\0 [UTF8 "co\x{f6}perative"] CUR = 12 LEN = 14 COW_REFCNT = 0 SV = PV(0xd6cb20) at 0xd977f0 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0xe0d120 "co\366perative"\0 CUR = 11 LEN = 14
source share