// AUTOGENERATED FROM index-cp437.txt, ORIGINAL COMMENT FOLLOWS: // // Source URL: ftp://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT // Keys have been shifted to be more like WHATWG's indexes. // // Name: cp437_DOSLatinUS to Unicode table // Unicode version: 2.0 // Table version: 2.00 // Table format: Format A // Date: 04/24/96 // Contact: Shawn.Steele@microsoft.com // // General notes: none // // Format: Three tab-separated columns // Column #1 is the cp437_DOSLatinUS code (in hex) // Column #2 is the Unicode (in hex as 0xXXXX) // Column #3 is the Unicode name (follows a comment sign, '#') // // The entries are in cp437_DOSLatinUS order // #[allow(dead_code)] const X: u16 = 0xffff; const FORWARD_TABLE: &[u16] = &[ 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197, 201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 162, 163, 165, 8359, 402, 225, 237, 243, 250, 241, 209, 170, 186, 191, 8976, 172, 189, 188, 161, 171, 187, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 945, 223, 915, 960, 931, 963, 181, 964, 934, 920, 937, 948, 8734, 966, 949, 8745, 8801, 177, 8805, 8804, 8992, 8993, 247, 8776, 176, 8729, 183, 8730, 8319, 178, 9632, 160, ]; // 128 entries /// Returns the index code point for pointer `code` in this index. #[inline] pub fn forward(code: u8) -> u16 { FORWARD_TABLE[(code - 0x80) as usize] } #[cfg(not(feature = "no-optimized-legacy-encoding"))] const BACKWARD_TABLE_LOWER: &[u8] = &[ 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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 0, 0, 0, 0, 0, 240, 0, 0, 243, 242, 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, 226, 0, 0, 0, 0, 233, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 228, 0, 0, 232, 0, 0, 234, 0, 0, 0, 0, 0, 0, 0, 224, 0, 0, 235, 238, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 142, 143, 146, 128, 0, 144, 0, 0, 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, 153, 0, 0, 0, 0, 0, 154, 0, 0, 225, 133, 160, 131, 0, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139, 0, 164, 149, 162, 147, 0, 148, 246, 0, 151, 163, 150, 129, 0, 0, 152, 223, 0, 0, 0, 220, 0, 0, 0, 219, 0, 0, 0, 221, 0, 0, 0, 222, 176, 177, 178, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 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, 255, 173, 155, 156, 0, 157, 0, 0, 0, 0, 166, 174, 170, 0, 0, 0, 248, 241, 253, 0, 0, 230, 0, 250, 0, 0, 167, 175, 172, 171, 0, 168, 227, 0, 0, 229, 231, 0, 237, 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, 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, 252, ]; // 678 entries #[cfg(not(feature = "no-optimized-legacy-encoding"))] const BACKWARD_TABLE_UPPER: &[u16] = &[ 0, 0, 543, 446, 0, 0, 125, 0, 0, 0, 0, 0, 0, 0, 386, 607, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 614, 150, 0, 0, 0, 0, 0, 237, 341, 0, 0, 198, 0, 0, 0, 0, 0, 0, 0, 64, 285, 510, ]; // 151 entries /// Returns the index pointer for code point `code` in this index. #[inline] #[cfg(not(feature = "no-optimized-legacy-encoding"))] pub fn backward(code: u32) -> u8 { let offset = (code >> 6) as usize; let offset = if offset < 151 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; BACKWARD_TABLE_LOWER[offset + ((code & 63) as usize)] } /// Returns the index pointer for code point `code` in this index. #[cfg(feature = "no-optimized-legacy-encoding")] pub fn backward(code: u32) -> u8 { if code > 9632 || ((0x70003u32 >> (code >> 9)) & 1) == 0 { return 0; } let code = code as u16; for i in 0..0x80 { if FORWARD_TABLE[i as usize] == code { return 0x80 + i; } } 0 } #[cfg(test)] encoding_index_tests::single_byte_tests! { }