unicode_script/
lib.rs

1// Copyright 2014 The html5ever Project Developers. See the
2// COPYRIGHT file at the top-level directory of this distribution.
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7// option. This file may not be copied, modified, or distributed
8// except according to those terms.
9
10//! Look up the script for a character.
11//!
12//! ### Example
13//!
14//! ```
15//! use unicode_script::{get_script, Script};
16//!
17//! assert_eq!(get_script('A'), Script::Latin);
18//! assert_eq!(get_script('カ'), Script::Katakana);
19//! ```
20
21pub mod script;
22pub mod tables;
23pub use script::get_script;
24pub use tables::Script;
25
26/// The version of [Unicode](http://www.unicode.org/)
27/// that this version of unicode-script is based on.
28pub const UNICODE_VERSION: (u64, u64, u64) = (16, 0, 0);
29
30#[cfg(test)]
31mod test {
32    use super::{get_script, Script};
33
34    #[test]
35    fn test_get_script() {
36        assert_eq!(get_script('a'), Script::Latin);
37        assert_eq!(get_script('.'), Script::Common);
38        assert_eq!(get_script('カ'), Script::Katakana);
39        assert_eq!(get_script('🦳'), Script::Common);
40    }
41}