Say I have a JSON with a 0xb7 byte encoded as a UTF codepoint:
{"key":"_\u00b7_"}
If I extract the value of the "key" with jq it keeps the utf8 encoding of this byte which is "c2 b7":
$ echo '{"key":"_\u00b7_"}' | ./jq '.key' -r | xxd
0000000: 5fc2 b75f 0a _.._.
Is there any jq command that extracts the decoded "5f b7 5f" byte sequence out of this JSON?
I can solve this with extra tools like iconv but it's a bit ugly:
$ echo '{"key":"_\u00b7_"}' | ./jq '.key' -r \
| iconv -f utf8 -t utf32le \
| xxd -ps | sed -e 's/000000//g' | xxd -ps -r \
| xxd
0000000: 5fb7 5f0a _._.