You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
helix/helix-stdx/src
Rolo 6fbc85e168 feat(stdx): add `str` mod with `unescape` function
This commit introduces a `str` module and an `unescape` function to
`helix-stdx`, which processes escape sequences in strings and converts
them into their corresponding literal characters. The function handles a
variety of escape sequences, including:

- `\n` for newlines
- `\t` for tabs
- `\u{...}` for Unicode characters

The function does not unescape sequences like `\\` to `\`, leaving them
as they are. This opinionated behavior ensures that only certain escape
sequences are processed, and is built around user input, not general
input.

Given that its based around user input, a conservative approach was
taken for handling bad input, where if the string cannot be processed as
expected, it returns the original input.

Examples:
- Converting escaped newlines: `unescape("hello\\nworld")` results in
`"hello\nworld"`.
- Converting escaped tabs: `unescape("hello\\tworld")` results in
`"hello\tworld"`.
- Converting Unicode escape sequences:
`unescape("hello\\u{1f929}world")` results in `"hello🤩world"`.
- Handling invalid Unicode escape sequence:
`unescape("hello\\u{999999999}world")` results in the original
`"hello\\u{999999999}world"`.

The implementation also includes tests, but no gaurantees for edgecases.
5 months ago
..
env.rs correctly handle opening helix inside symlinked directory (#10728) 6 months ago
faccess.rs Use a temporary file for writes (#9236) 8 months ago
lib.rs feat(stdx): add `str` mod with `unescape` function 5 months ago
path.rs Use the OS path separator instead of / (#10000) 8 months ago
rope.rs don't manually grapheme align ts highlights (#10310) 8 months ago
str.rs feat(stdx): add `str` mod with `unescape` function 5 months ago