antonmedv/fx

Feature Request: output unescaped valid UTF-8 sequences

taoky opened this issue · 1 comments

Currently, fx could handle non-ascii UTF-8 in JSON if they are not escaped:

> echo '{"test": "测试"}' | fx

image

However, when these non-ascii characters are escaped, fx just outputs them as-is, which is inconvenient in some cases:

> echo '{"test": "\u6d4b\u8bd5"}' | fx

image

Jq, by default:

jq usually outputs non-ASCII Unicode codepoints as UTF-8, even if the input specified them as escape sequences (like "\u03bc").

> echo '{"test": "\u6d4b\u8bd5"}' | jq .
{
  "test": "测试"
}

Versions:

  • fx 30.0.3
  • jq 1.7

I think this is actually a cool feature. Fx output for "evaluated" strings, but rather original strings, as they are.

To get an evaluated string you can simply pass output to fx one more time:

echo '{"test": "\u6d4b\u8bd5"}' | fx . | fx
Screenshot 2023-09-22 at 18 59 50