//! This crate exposes the Unicode `Script` and `Script_Extension` //! properties from [UAX #24](http://www.unicode.org/reports/tr24/) #![cfg_attr(not(test), no_std)] #![cfg_attr(feature = "bench", feature(test))] mod tables; use core::convert::TryFrom; use core::fmt; use core::u64; pub use tables::script_extensions; use tables::{get_script, get_script_extension, NEXT_SCRIPT}; pub use tables::{Script, UNICODE_VERSION}; impl Script { /// Get the full name of a script. pub fn full_name(self) -> &'static str { self.inner_full_name() } /// Attempts to parse script name from the provided string. /// Returns `None` if the provided string does not represent a valid /// script full name. pub fn from_full_name(input: &str) -> Option { Self::inner_from_full_name(input) } /// Get the four-character short name of a script. pub fn short_name(self) -> &'static str { self.inner_short_name() } /// Attempts to parse script name from the provided string. /// Returns `None` if the provided string does not represent a valid /// script four-character short name. pub fn from_short_name(input: &str) -> Option { Self::inner_from_short_name(input) } /// Is this script "Recommended" according to /// [UAX #31](www.unicode.org/reports/tr31/#Table_Recommended_Scripts)? pub fn is_recommended(self) -> bool { use Script::*; match self { Common | Inherited | Arabic | Armenian | Bengali | Bopomofo | Cyrillic | Devanagari | Ethiopic | Georgian | Greek | Gujarati | Gurmukhi | Han | Hangul | Hebrew | Hiragana | Kannada | Katakana | Khmer | Lao | Latin | Malayalam | Myanmar | Oriya | Sinhala | Tamil | Telugu | Thaana | Thai | Tibetan => true, _ => false, } } } impl From