encoding_index_singlebyte/
x_mac_cyrillic.rs

1// AUTOGENERATED FROM index-x-mac-cyrillic.txt, ORIGINAL COMMENT FOLLOWS:
2//
3// For details on index index-x-mac-cyrillic.txt see the Encoding Standard
4// https://encoding.spec.whatwg.org/
5//
6// Identifier: 73e8e7642c6fa9de29d42819b47fba55b58666fb1e339faeb4a89a0bd7c24d43
7// Date: 2018-01-06
8
9#[allow(dead_code)] const X: u16 = 0xffff;
10
11const FORWARD_TABLE: &[u16] = &[
12    1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055,
13    1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071,
14    8224, 176, 1168, 163, 167, 8226, 182, 1030, 174, 169, 8482, 1026, 1106, 8800, 1027, 1107, 8734,
15    177, 8804, 8805, 1110, 181, 1169, 1032, 1028, 1108, 1031, 1111, 1033, 1113, 1034, 1114, 1112,
16    1029, 172, 8730, 402, 8776, 8710, 171, 187, 8230, 160, 1035, 1115, 1036, 1116, 1109, 8211,
17    8212, 8220, 8221, 8216, 8217, 247, 8222, 1038, 1118, 1039, 1119, 8470, 1025, 1105, 1103, 1072,
18    1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088,
19    1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 8364,
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    173, 0, 0, 0, 178, 179, 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, 220, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
33    0, 0, 0, 0, 0, 162, 182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 197, 0, 0, 0, 0, 0, 0, 0, 0,
34    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 198,
35    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 195, 0, 0, 0, 176, 0, 144, 145, 146,
36    147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 224, 225, 226, 227, 228, 229,
37    230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 160, 0, 165, 0, 0, 0, 201, 0, 0, 0, 0, 0, 0,
38    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 209, 0, 0, 0, 212, 213, 0, 0,
39    210, 211, 215, 0, 202, 0, 0, 163, 0, 0, 0, 164, 0, 169, 0, 199, 194, 0, 168, 0, 161, 177, 0, 0,
40    0, 181, 166, 0, 0, 0, 0, 200, 0, 0, 0, 0, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
41    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 214, 0, 0, 0, 0, 0, 0, 0, 0, 221, 171, 174, 184, 193,
42    167, 186, 183, 188, 190, 203, 205, 0, 216, 218, 128, 129, 130, 131, 132, 133, 134, 135, 136,
43    137, 138, 139, 140, 141, 142, 143, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
44    252, 253, 254, 223, 0, 222, 172, 175, 185, 207, 180, 187, 192, 189, 191, 204, 206, 0, 217, 219,
45]; // 388 entries
46
47#[cfg(not(feature = "no-optimized-legacy-encoding"))]
48const BACKWARD_TABLE_UPPER: &[u16] = &[
49    0, 0, 0, 0, 0, 254, 0, 293, 0, 0, 0, 0, 119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50    0, 0, 324, 177, 356, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51    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,
52    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,
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, 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,
57    0, 0, 0, 0, 0, 222, 209, 0, 0, 0, 65, 0, 0, 42, 284, 0, 0, 0, 0, 0, 0, 145, 0, 105, 32,
58]; // 276 entries
59
60/// Returns the index pointer for code point `code` in this index.
61#[inline]
62#[cfg(not(feature = "no-optimized-legacy-encoding"))]
63pub fn backward(code: u32) -> u8 {
64    let offset = (code >> 5) as usize;
65    let offset = if offset < 276 {BACKWARD_TABLE_UPPER[offset] as usize} else {0};
66    BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)]
67}
68
69/// Returns the index pointer for code point `code` in this index.
70#[cfg(feature = "no-optimized-legacy-encoding")]
71pub fn backward(code: u32) -> u8 {
72    if code > 8805 || ((0x30005u32 >> (code >> 9)) & 1) == 0 { return 0; }
73    let code = code as u16;
74    for i in 0..0x80 {
75        if FORWARD_TABLE[i as usize] == code { return 0x80 + i; }
76    }
77    0
78}
79
80#[cfg(test)]
81encoding_index_tests::single_byte_tests! {
82}