1 #![unstable(feature = "unicode_internals", issue = "none")]
2 #![allow(missing_docs)]
4 pub(crate) mod printable;
6 pub(crate) mod version;
8 use version::UnicodeVersion;
10 /// The version of [Unicode](http://www.unicode.org/) that the Unicode parts of
11 /// `char` and `str` methods are based on.
12 #[unstable(feature = "unicode_version", issue = "49726")]
13 pub const UNICODE_VERSION: UnicodeVersion = UnicodeVersion {
14 major: unicode_data::UNICODE_VERSION.0,
15 minor: unicode_data::UNICODE_VERSION.1,
16 micro: unicode_data::UNICODE_VERSION.2,
20 // For use in liballoc, not re-exported in libstd.
21 pub mod derived_property {
22 pub use super::{Case_Ignorable, Cased};
25 pub use unicode_data::alphabetic::lookup as Alphabetic;
26 pub use unicode_data::case_ignorable::lookup as Case_Ignorable;
27 pub use unicode_data::cased::lookup as Cased;
28 pub use unicode_data::cc::lookup as Cc;
29 pub use unicode_data::conversions;
30 pub use unicode_data::grapheme_extend::lookup as Grapheme_Extend;
31 pub use unicode_data::lowercase::lookup as Lowercase;
32 pub use unicode_data::n::lookup as N;
33 pub use unicode_data::uppercase::lookup as Uppercase;
34 pub use unicode_data::white_space::lookup as White_Space;
39 const CHUNK_SIZE: usize,
41 const CANONICAL: usize,
42 const CANONICALIZED: usize,
45 chunk_idx_map: &[u8; N],
46 (last_chunk_idx, last_chunk_mapping): (u16, u8),
47 bitset_chunk_idx: &[[u8; CHUNK_SIZE]; N1],
48 bitset_canonical: &[u64; CANONICAL],
49 bitset_canonicalized: &[(u8, u8); CANONICALIZED],
51 let bucket_idx = (needle / 64) as usize;
52 let chunk_map_idx = bucket_idx / CHUNK_SIZE;
53 let chunk_piece = bucket_idx % CHUNK_SIZE;
54 let chunk_idx = if chunk_map_idx >= N {
55 if chunk_map_idx == last_chunk_idx as usize {
61 chunk_idx_map[chunk_map_idx]
63 let idx = bitset_chunk_idx[(chunk_idx as usize)][chunk_piece] as usize;
64 let word = if idx < CANONICAL {
67 let (real_idx, mapping) = bitset_canonicalized[idx - CANONICAL];
68 let mut word = bitset_canonical[real_idx as usize];
69 let should_invert = mapping & (1 << 7) != 0;
73 // Unset the inversion bit
74 let rotate_by = mapping & !(1 << 7);
75 word = word.rotate_left(rotate_by as u32);
78 (word & (1 << (needle % 64) as u64)) != 0