encoding_index_singlebyte/
iso_8859_4.rs

1// AUTOGENERATED FROM index-iso-8859-4.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-iso-8859-4.txt see the Encoding Standard
7// https://encoding.spec.whatwg.org/
8//
9// Identifier: 72f29c92344d351fe9e74a946e7e0468d76d542c6894ff82982cb652ebe0feb7
10// Date: 2014-12-19
11
12static FORWARD_TABLE: &'static [u16] = &[
13    128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
14    143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
15    158, 159, 160, 260, 312, 342, 164, 296, 315, 167, 168, 352, 274, 290, 358,
16    173, 381, 175, 176, 261, 731, 343, 180, 297, 316, 711, 184, 353, 275, 291,
17    359, 330, 382, 331, 256, 193, 194, 195, 196, 197, 198, 302, 268, 201, 280,
18    203, 278, 205, 206, 298, 272, 325, 332, 310, 212, 213, 214, 215, 216, 370,
19    218, 219, 220, 360, 362, 223, 257, 225, 226, 227, 228, 229, 230, 303, 269,
20    233, 281, 235, 279, 237, 238, 299, 273, 326, 333, 311, 244, 245, 246, 247,
21    248, 371, 250, 251, 252, 361, 363, 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, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
33    139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
34    154, 155, 156, 157, 158, 159, 160, 0, 0, 0, 164, 0, 0, 167, 168, 0, 0, 0,
35    0, 173, 0, 175, 176, 0, 0, 0, 180, 0, 0, 0, 184, 0, 0, 0, 0, 0, 0, 0, 0,
36    193, 194, 195, 196, 197, 198, 0, 0, 201, 0, 203, 0, 205, 206, 0, 0, 0, 0,
37    0, 212, 213, 214, 215, 216, 0, 218, 219, 220, 0, 0, 223, 0, 225, 226, 227,
38    228, 229, 230, 0, 0, 233, 0, 235, 0, 237, 238, 0, 0, 0, 0, 0, 244, 245,
39    246, 247, 248, 0, 250, 251, 252, 0, 0, 0, 192, 224, 0, 0, 161, 177, 0, 0,
40    0, 0, 0, 0, 200, 232, 0, 0, 208, 240, 170, 186, 0, 0, 204, 236, 202, 234,
41    0, 0, 0, 0, 0, 0, 0, 0, 171, 187, 0, 0, 0, 0, 165, 181, 207, 239, 0, 0,
42    199, 231, 0, 0, 0, 0, 0, 0, 211, 243, 162, 0, 0, 166, 182, 0, 0, 0, 0, 0,
43    0, 0, 0, 209, 241, 0, 0, 0, 189, 191, 210, 242, 0, 0, 0, 0, 0, 0, 0, 0,
44    163, 179, 0, 0, 0, 0, 0, 0, 0, 0, 169, 185, 0, 0, 0, 0, 172, 188, 221, 253,
45    222, 254, 0, 0, 0, 0, 0, 0, 217, 249, 0, 0, 0, 0, 0, 0, 0, 0, 0, 174, 190,
46    0, 0, 0, 0, 0, 0, 0, 0, 183, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47    0, 0, 255, 0, 178, 0, 0, 0, 0,
48];
49
50static BACKWARD_TABLE_UPPER: &'static [u16] = &[
51    0, 0, 0, 0, 32, 64, 96, 128, 160, 192, 224, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52    0, 288,
53];
54
55/// Returns the index pointer for code point `code` in this index.
56#[inline]
57pub fn backward(code: u32) -> u8 {
58    let offset = (code >> 5) as usize;
59    let offset = if offset < 23 {BACKWARD_TABLE_UPPER[offset] as usize} else {0};
60    BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)]
61}
62
63#[cfg(test)]
64single_byte_tests!(
65    mod = iso_8859_4
66);