utf16_position

Function utf16_position 

Source
pub fn utf16_position(text: &str, offset: u32) -> (u32, u32)
Expand description

A byte offset as a zero-based line and UTF-16 character offset.

UTF-16 because that is what LSP specifies by default, and getting it wrong is invisible until somebody writes an emoji in a string literal — which beck-syntax’s own security tests say they will. SourceMap::line_col counts characters and is one-based, so it is the wrong unit twice over and is deliberately not used here.