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

What would it take to support UTF16 encoding? #192

Open
kentookura opened this issue Jan 12, 2025 · 3 comments
Open

What would it take to support UTF16 encoding? #192

kentookura opened this issue Jan 12, 2025 · 3 comments

Comments

@kentookura
Copy link

kentookura commented Jan 12, 2025

@TOTBWF

As reported by @Trebor-Huang in Trebor-Huang/vscode-forester#11 (comment), it seems that the VSCode LSP client refuses to work with UTF16 encoded positions. I was wondering if you could say a few words about the trouble you mention here?

Thanks!

@favonia
Copy link
Contributor

favonia commented Jan 12, 2025

@kentookura To support UTF-16 efficiently, we need to avoid the recalculation of the byte offset of a UTF-16 unit when files change. This can be done by... (1) inefficient recalculation (oops) or (2) some smart data structure maintaining the mapping.

@favonia
Copy link
Contributor

favonia commented Jan 12, 2025

For ASCII printable characters, I believe byte offsets and UTF-16 units coincide.

@TOTBWF
Copy link
Collaborator

TOTBWF commented Jan 12, 2025

Ugh, VSCode being a bad citizen yet again...

As for the data structure, I think some sort of rope segmented at points where UTF-16 and UTF-8 offsets disagree ought to work. Nodes further up the tree could then store both the UTF-8 and UTF-16 range that the subtree covers, so we'd get efficient queries in both directions.

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

3 participants