encoding_index_singlebyte/
iso_8859_15.rs

1// AUTOGENERATED FROM index-iso-8859-15.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-15.txt see the Encoding Standard
7// https://encoding.spec.whatwg.org/
8//
9// Identifier: a560aba47bccd7510a6ac77f671fe75dca3800f05cf6d676910c311a8f8ff079
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, 161, 162, 163, 8364, 165, 352, 167, 353, 169, 170, 171, 172,
16    173, 174, 175, 176, 177, 178, 179, 381, 181, 182, 183, 382, 185, 186, 187,
17    338, 339, 376, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202,
18    203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
19    218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232,
20    233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
21    248, 249, 250, 251, 252, 253, 254, 255,
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, 128, 129, 130, 131, 132, 133,
34    134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
35    149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
36    0, 165, 0, 167, 0, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
37    0, 181, 182, 183, 0, 185, 186, 187, 0, 0, 0, 191, 192, 193, 194, 195, 196,
38    197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211,
39    212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226,
40    227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,
41    242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 0, 0,
42    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 188, 189, 0, 0, 0, 0, 0, 0,
43    0, 0, 0, 0, 0, 0, 166, 168, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44    0, 0, 0, 0, 0, 0, 190, 0, 0, 0, 0, 180, 184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
45    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,
46    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47    0, 0, 0, 0, 0, 0,
48];
49
50static BACKWARD_TABLE_UPPER: &'static [u16] = &[
51    0, 0, 64, 128, 0, 192, 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,
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, 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,
56    0, 0, 0, 0, 0, 0, 0, 256,
57];
58
59/// Returns the index pointer for code point `code` in this index.
60#[inline]
61pub fn backward(code: u32) -> u8 {
62    let offset = (code >> 6) as usize;
63    let offset = if offset < 131 {BACKWARD_TABLE_UPPER[offset] as usize} else {0};
64    BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)]
65}
66
67#[cfg(test)]
68single_byte_tests!(
69    mod = iso_8859_15
70);