encoding_index_singlebyte/
windows_1255.rs

1// AUTOGENERATED FROM index-windows-1255.txt, ORIGINAL COMMENT FOLLOWS:
2//
3// For details on index index-windows-1255.txt see the Encoding Standard
4// https://encoding.spec.whatwg.org/
5//
6// Identifier: cd7fb43c97eefa1651084d92d02af53ad668bd848528c18c3b1af5c06b499651
7// Date: 2018-01-06
8
9#[allow(dead_code)] const X: u16 = 0xffff;
10
11const FORWARD_TABLE: &[u16] = &[
12    8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 138, 8249, 140, 141, 142, 143, 144,
13    8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 156, 157, 158, 159, 160, 161,
14    162, 163, 8362, 165, 166, 167, 168, 169, 215, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
15    181, 182, 183, 184, 185, 247, 187, 188, 189, 190, 191, 1456, 1457, 1458, 1459, 1460, 1461,
16    1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1520, 1521,
17    1522, 1523, 1524, X, X, X, X, X, X, X, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496,
18    1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512,
19    1513, 1514, X, X, 8206, 8207, X,
20]; // 128 entries
21
22/// Returns the index code point for pointer `code` in this index.
23#[inline]
24pub fn forward(code: u8) -> u16 {
25    FORWARD_TABLE[(code - 0x80) as usize]
26}
27
28#[cfg(not(feature = "no-optimized-legacy-encoding"))]
29const BACKWARD_TABLE_LOWER: &[u8] = &[
30    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, 0, 0, 0, 0, 0, 0, 0,
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, 0, 0, 0, 0, 0, 0, 0,
32    136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0,
33    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, 0, 0, 0, 0, 0, 0, 0,
34    0, 0, 0, 164, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
35    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36    0, 0, 0, 0, 0, 0, 0, 0, 0, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
37    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 253, 254, 0, 0, 0,
38    150, 151, 0, 0, 0, 145, 146, 130, 0, 147, 148, 132, 0, 134, 135, 149, 0, 0, 0, 133, 0, 0, 0, 0,
39    0, 0, 0, 0, 0, 137, 0, 0, 0, 0, 0, 0, 0, 0, 139, 155, 0, 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, 0, 0,
40    0, 138, 0, 140, 141, 142, 143, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 154, 0, 156, 157, 158, 159, 160,
41    161, 162, 163, 0, 165, 166, 167, 168, 169, 0, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
42    181, 182, 183, 184, 185, 0, 187, 188, 189, 190, 191, 208, 209, 210, 211, 0, 0, 0, 0, 0, 0, 0,
43    0, 0, 0, 0, 0, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
44    240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 0, 0, 0, 0, 0, 212, 213, 214, 215, 216,
45    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46    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, 0, 0, 0, 0, 0, 0, 0,
47    0, 0, 0, 0, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
48]; // 492 entries
49
50#[cfg(not(feature = "no-optimized-legacy-encoding"))]
51const BACKWARD_TABLE_UPPER: &[u16] = &[
52    0, 0, 292, 173, 0, 0, 409, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 428, 356, 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, 0, 0, 0, 0, 0, 0, 0,
54    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, 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, 0, 0, 0, 0, 0, 0, 0,
56    0, 0, 0, 0, 229, 0, 87, 0, 132,
57]; // 133 entries
58
59/// Returns the index pointer for code point `code` in this index.
60#[inline]
61#[cfg(not(feature = "no-optimized-legacy-encoding"))]
62pub fn backward(code: u32) -> u8 {
63    let offset = (code >> 6) as usize;
64    let offset = if offset < 133 {BACKWARD_TABLE_UPPER[offset] as usize} else {0};
65    BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)]
66}
67
68/// Returns the index pointer for code point `code` in this index.
69#[cfg(feature = "no-optimized-legacy-encoding")]
70pub fn backward(code: u32) -> u8 {
71    if code > 8482 || ((0x10007u32 >> (code >> 9)) & 1) == 0 { return 0; }
72    let code = code as u16;
73    for i in 0..0x80 {
74        if FORWARD_TABLE[i as usize] == code { return 0x80 + i; }
75    }
76    0
77}
78
79#[cfg(test)]
80encoding_index_tests::single_byte_tests! {
81}