Add support for translating between character offsets and code point indices #14
Open
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Problem
Related: syntax-tree/unist#99.
remark-lint where a user provides a max size of say 80, and they don’t mean the way that JS stores strings.
To check if things are (not) allowed at that point, a lint tool needs to be aware of that difference, and be able to translate between the two.
Solution
Two new methods: toCodePointIndex(offset: number): number
/ fromCodePointIndex(index: number): number
Alternatives
Different utility.