Bug#879790: State clearly what "utf8" you are talking about

積丹尼 Dan Jacobson jidanni at jidanni.org
Wed Oct 25 21:35:03 UTC 2017


Package: libjson-perl
Version: 2.94-1
File: /usr/share/man/man3/JSON.3pm.gz

We read

SYNOPSIS
        use JSON; # imports encode_json, decode_json, to_json and from_json.

        # simple and fast interfaces (expect/generate UTF-8)

        $utf8_encoded_json_text = encode_json $perl_hash_or_arrayref;
        $perl_hash_or_arrayref  = decode_json $utf8_encoded_json_text;

Then



       "utf8" flag disabled
           When "utf8" is disabled (the default), then "encode"/"decode"...
       "utf8" flag enabled
           If the "utf8"-flag is enabled, "encode"/"decode" will encode all
           characters using the corresponding UTF-8 multi-byte sequence, and
           will expect your input strings to be encoded as UTF-8, that is, no


OK, if the default is "disabled", then
        $perl_hash_or_arrayref  = decode_json $utf8_encoded_json_text;
would seem bad, because you said you expect ...

OR maybe the "utf8 flag" is referring to the "perl utf8 flag" and not
the "JSON utf8 flag". (Conclusion A).

Wait, further up the page we see

   utf8
           $json = $json->utf8([$enable])

           $enabled = $json->get_utf8

       If $enable is true (or missing), then the "encode" method will encode
       the JSON result into UTF-8, as required by many protocols, while the

So this rather confirms my Conclusion A.

Therefore please be sure to state clearly every time you say "utf8"
which one your are talking about. Yes even if one is a flag and the
other is not a flag.



More information about the pkg-perl-maintainers mailing list