Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountered a reversible "cat -v"? #3

Open
Intensity opened this issue Jan 3, 2023 · 2 comments
Open

Encountered a reversible "cat -v"? #3

Intensity opened this issue Jan 3, 2023 · 2 comments

Comments

@Intensity
Copy link

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.

@ghost
Copy link

ghost commented Aug 17, 2023

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.

@pete
Copy link
Owner

pete commented Dec 14, 2023

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants