makamaka/JSON-PP — pull request #12 by 2shortplanks (2014-09-12 16:32:39+00:00)
Title: Also escape \x{7f}, test ctl char escaping

So here's me story. I attempted to print out **four** characters that I got from packing an int:

use JSON::PP;
my $bytes = pack "l", 2147483647; # length $bytes is 4
say JSON::PP->new->ascii->encode([$bytes])

And it printed out on screen what looks like **three** characters:

["\u00ff\u00ff\u00ff"]

There was much, much scratching of heads. Why are there only four characters? Because the last byte is `\x{7f}` and JSON::PP was printing it directly to the terminal as a zero-width invisible character. This isn't consistent with the way JSON::PP turns other control chars into `\uXXXX` sequences.

This patch adds `\x{7f}` as something that should be escaped, and adds tests for those escapes