cats icon indicating copy to clipboard operation
cats copied to clipboard

Encountered a reversible "cat -v"?

Open Intensity opened this issue 3 years ago • 2 comments

Hi!

I'm wondering if you've come across a cat implementation that produces cat -v output that can be uniquely reversed back to the original. It may not be a historical version, but if you have looked into these cats extensively, you may have come across this functionality.

I stumbled upon a project that did just that about a year or two ago, found it interesting, but despite repeatedly combing the web for this (by searching for terms like "invertible", "reversible", "bijective", etc), I can't seem to find it again. It may have been BSD based.

By cat -v, I mean at a high level turning unprintable characters into escaped ones, coded in ASCII. I often do just that, but it would be a nice plus to get back the original should I want it.

Intensity avatar Jan 03 '23 02:01 Intensity

As far as I know, you cant.

cat -v mixes raw data and encoded one.

For example, what do you think the following will decode to?

^W

Will it be Control-W or literal ^W (carrot and W)? You can't actually know without a context from where this came from. Computers can't understand the context of a text.

cat -v is not meant to be machine-readable, it's meant to be human-readable.

ghost avatar Aug 17 '23 02:08 ghost

I should probably mention that I haven't seen something like this and I believe @jumps-are-op is correct.

You could probably do it in such a way that it usually works, by detecting sequences that could be reversed and sequences that -v would translate and the presence of the latter would indicate that it hadn't been -v'd yet. (On the other hand, the value is dubious.)

pete avatar Dec 14 '23 19:12 pete