1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Target encoding definitions for column-width measurement.
//!
//! A [`CharEncoding`] answers "how many code units does this character occupy
//! in a given encoding?" This is used by [`super::source_loc::SourceLocConverter`]
//! to translate byte offsets into columns that match a client's expected encoding
//! (e.g., UTF-16 for LSP).
/// Measures the width of a `char` in a target encoding's code units.
///
/// This is the number of code units the target system uses to represent
/// this character, *not* the byte width in the source file.
/// This is *not* the byte width in the source file.
/// UTF-8: 1–4 code units (bytes) per character.
;
/// UTF-16: 1–2 code units (16-bit) per character. This is the LSP default.
;
/// UTF-32 / code point index: always 1 unit per character.
;
/// Latin-1: always 1 unit per character.
/// Identical to [`Utf32`] for column measurement since every Latin-1
/// character is a single code point.
;