1static 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, 65535, 162, 163, 164, 165, 166, 167, 168, 169, 215, 171,
16 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 247,
17 187, 188, 189, 190, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
18 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
19 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
20 65535, 65535, 65535, 65535, 8215, 1488, 1489, 1490, 1491, 1492, 1493, 1494,
21 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506,
22 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 65535, 65535, 8206, 8207,
23 65535,
24];
25
26#[inline]
28pub fn forward(code: u8) -> u16 {
29 FORWARD_TABLE[(code - 0x80) as usize]
30}
31
32static BACKWARD_TABLE_LOWER: &'static [u8] = &[
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,
34 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,
35 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133,
36 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
37 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 0, 162, 163,
38 164, 165, 166, 167, 168, 169, 0, 171, 172, 173, 174, 175, 176, 177, 178,
39 179, 180, 181, 182, 183, 184, 185, 0, 187, 188, 189, 190, 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, 170, 0, 0, 0, 0, 0,
41 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,
42 0, 186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
43 0, 0, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
44 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 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, 253, 254, 0, 0, 0, 0, 0, 0, 0, 223, 0, 0, 0, 0, 0, 0,
47 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,
48 0, 0, 0, 0, 0, 0, 0, 0, 0,
49];
50
51static BACKWARD_TABLE_UPPER: &'static [u16] = &[
52 0, 0, 64, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53 192, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 0, 0, 0, 0, 0, 0, 256,
58];
59
60#[inline]
62pub fn backward(code: u32) -> u8 {
63 let offset = (code >> 6) as usize;
64 let offset = if offset < 129 {BACKWARD_TABLE_UPPER[offset] as usize} else {0};
65 BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)]
66}
67
68#[cfg(test)]
69single_byte_tests!(
70 mod = iso_8859_8
71);