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

Support ANSI escapes in strings by replacing \x1b with ␛ #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

colinta
Copy link

@colinta colinta commented Nov 25, 2024

There is a library that I saw the other day that does exactly this - replaces ASCII control characters with a sigil... but now I can't find it. @sindresorhus I think I saw it in one of your projects, do you remember what it was called?

Anyway I needed to hack this up to get unblocked, and I had this bit of replacement locally so I used that. (I'm using DC1-4 in a similar way that you're using CONTROL_PICTURE so they show up in my strings). I left them in specifically because they're a bit of a code smell. Why only these 5 sigils? Why not all the ASCII control characters?

I wonder if this would be better handled as an option to concordance... but then again I don't think it's a bad thing to output these control characters as printable characters, so the argument for having it be the default behaviour could be made.

Anyway I'll propose this as a starting point, but I don't think it's polished and ready - I'm happy to do more work on it.

@colinta
Copy link
Author

colinta commented Nov 25, 2024

The output in ava is now exactly what I'd hope for - though I'm confused as to why the escape sequence is colored differently! But I like it:
image

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

Successfully merging this pull request may close these issues.

1 participant