in reply to Re: Converting entities in JSON context
in thread Converting entities in JSON context

I'm not sure I understand. It doesn't seem to be about the display only. If I write a test for this (which is where I originally discovered this situation), something like:

is($decoded_JSON->{'school'}, "Eötvös Loránd University", "convert_ent +ities correctly converted HTML entities in a JSON context, and yielde +d good JSON at the end");

, this test fails. What should I be expecting from the test, or how do I write a test to make sure that the JSON I'm sending is what I should be sending?

Replies are listed 'Best First'.
Re^3: Converting entities in JSON context
by choroba (Cardinal) on May 19, 2022 at 13:00 UTC
    Here, you're using non-ASCII characters in the source code (the second argument to is).

    To tell Perl how to interpret them, you need to

    use utf8;

    This makes Perl interpret the part of the source in the lexical scope of the pragma as UTF-8 encoded. ( Update: And you need to save the source as UTF-8, too, of course.)

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      D'oh! Yes, of course! Makes sense now. Thank you!