unescaper icon indicating copy to clipboard operation
unescaper copied to clipboard

feat: Unfailable unescaper

Open Rosuavio opened this issue 10 months ago • 3 comments

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 avatar Apr 19 '24 15:04 Rosuavio

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

Rosuavio avatar Apr 19 '24 15:04 Rosuavio

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?

aurexav avatar Apr 23 '24 06:04 aurexav

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)

Rosuavio avatar Apr 23 '24 20:04 Rosuavio