encoding_index_singlebyte/
windows_1257.rs

1// AUTOGENERATED FROM index-windows-1257.txt, ORIGINAL COMMENT FOLLOWS:
2//
3// Any copyright is dedicated to the Public Domain.
4// https://creativecommons.org/publicdomain/zero/1.0/
5//
6// For details on index index-windows-1257.txt see the Encoding Standard
7// https://encoding.spec.whatwg.org/
8//
9// Identifier: cc7256bdd10a5b8dc7fb6f994659f307dfcae60def9aa6c29d811f85e2842c47
10// Date: 2014-12-19
11
12static FORWARD_TABLE: &'static [u16] = &[
13    8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240, 138, 8249, 140,
14    168, 711, 184, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482,
15    154, 8250, 156, 175, 731, 159, 160, 65535, 162, 163, 164, 65535, 166, 167,
16    216, 169, 342, 171, 172, 173, 174, 198, 176, 177, 178, 179, 180, 181, 182,
17    183, 248, 185, 343, 187, 188, 189, 190, 230, 260, 302, 256, 262, 196, 197,
18    280, 274, 268, 201, 377, 278, 290, 310, 298, 315, 352, 323, 325, 211, 332,
19    213, 214, 215, 370, 321, 346, 362, 220, 379, 381, 223, 261, 303, 257, 263,
20    228, 229, 281, 275, 269, 233, 378, 279, 291, 311, 299, 316, 353, 324, 326,
21    243, 333, 245, 246, 247, 371, 322, 347, 363, 252, 380, 382, 729,
22];
23
24/// Returns the index code point for pointer `code` in this index.
25#[inline]
26pub fn forward(code: u8) -> u16 {
27    FORWARD_TABLE[(code - 0x80) as usize]
28}
29
30static BACKWARD_TABLE_LOWER: &'static [u8] = &[
31    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
32    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
33    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 131, 0, 0, 0, 0, 136,
34    0, 138, 0, 140, 0, 0, 0, 144, 0, 0, 0, 0, 0, 0, 0, 152, 0, 154, 0, 156, 0,
35    0, 159, 160, 0, 162, 163, 164, 0, 166, 167, 141, 169, 0, 171, 172, 173,
36    174, 157, 176, 177, 178, 179, 180, 181, 182, 183, 143, 185, 0, 187, 188,
37    189, 190, 0, 0, 0, 0, 0, 196, 197, 175, 0, 0, 201, 0, 0, 0, 0, 0, 0, 0, 0,
38    0, 211, 0, 213, 214, 215, 168, 0, 0, 0, 220, 0, 0, 223, 0, 0, 0, 0, 228,
39    229, 191, 0, 0, 233, 0, 0, 0, 0, 0, 0, 0, 0, 0, 243, 0, 245, 246, 247, 184,
40    0, 0, 0, 252, 0, 0, 0, 194, 226, 0, 0, 192, 224, 195, 227, 0, 0, 0, 0, 200,
41    232, 0, 0, 0, 0, 199, 231, 0, 0, 203, 235, 198, 230, 0, 0, 0, 0, 0, 0, 0,
42    0, 204, 236, 0, 0, 0, 0, 0, 0, 206, 238, 0, 0, 193, 225, 0, 0, 0, 0, 0, 0,
43    205, 237, 0, 0, 0, 207, 239, 0, 0, 0, 0, 217, 249, 209, 241, 210, 242, 0,
44    0, 0, 0, 0, 212, 244, 0, 0, 0, 0, 0, 0, 0, 0, 170, 186, 0, 0, 218, 250, 0,
45    0, 0, 0, 208, 240, 0, 0, 0, 0, 0, 0, 0, 0, 219, 251, 0, 0, 0, 0, 0, 0, 216,
46    248, 0, 0, 0, 0, 0, 202, 234, 221, 253, 222, 254, 0, 0, 0, 0, 0, 0, 0, 0,
47    142, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 158, 0, 0,
48    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
49    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50    0, 0, 0, 150, 151, 0, 0, 0, 145, 146, 130, 0, 147, 148, 132, 0, 134, 135,
51    149, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, 0, 0, 0, 0,
52    139, 155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54    0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56    0, 0, 0, 0, 0, 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58];
59
60static BACKWARD_TABLE_UPPER: &'static [u16] = &[
61    0, 0, 64, 128, 192, 256, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
62    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
63    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
64    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
65    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
66    0, 0, 0, 0, 0, 0, 384, 0, 448, 0, 512,
67];
68
69/// Returns the index pointer for code point `code` in this index.
70#[inline]
71pub fn backward(code: u32) -> u8 {
72    let offset = (code >> 6) as usize;
73    let offset = if offset < 133 {BACKWARD_TABLE_UPPER[offset] as usize} else {0};
74    BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)]
75}
76
77#[cfg(test)]
78single_byte_tests!(
79    mod = windows_1257
80);