encoding_index_singlebyte/
iso_8859_10.rs

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