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

feat: Unfailable unescaper #41

Open
Rosuavio opened this issue Apr 19, 2024 · 3 comments
Open

feat: Unfailable unescaper #41

Rosuavio opened this issue Apr 19, 2024 · 3 comments

Comments

@Rosuavio
Copy link

Rosuavio commented Apr 19, 2024

Would it be appropriate for this project to also include version of unescape that cannot fail? Specifically where it would fail at unescaping it just shows the original string, but it continues to try to unescape the rest of the string.

For context I need something with the behavior similar to glib's g_strcompress.

@Rosuavio
Copy link
Author

If it would be appropriate for this project, I would be interested in working on a PR.

@AurevoirXavier
Copy link
Member

Would it be appropriate for this project to also include version of unescape that cannot fail?

I'm not familiar with glib, but would unescape(s).unwrap_or(s) do the trick? Is necessary to add another function?

@Rosuavio
Copy link
Author

Rosuavio commented Apr 23, 2024

No, it's really more of a best attempt of unescaping. So unescaping what can be unescaped and leaving the rest, in a sort of left to right fashion. They call it "compressing" but is essentially the same idea as unescaping.

If you want to give it a try, use notify-send on a compatible system (probably only Linux distros) and play with the body argument (the second positional argument), as it is passed directly to g_strcompress. It allows the user to type something like \n on the command line and have the two individual characters be transferred into a single newline character (it handles more sequences other than \n)

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