diff --git a/src/lib.rs b/src/lib.rs index d33f307..3872a03 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ mod tables; -use core::convert::TryFrom; +use core::convert::{TryFrom, TryInto}; use core::fmt; use core::u64; pub use tables::script_extensions; @@ -38,6 +38,12 @@ impl Script { Self::inner_from_short_name(input) } + /// The 4-byte iso15924 tag as a big-endian `u32` + pub fn as_iso15924_tag(self) -> u32 { + let arr: [u8; 4] = self.inner_short_name().as_bytes().try_into().unwrap(); + u32::from_be_bytes(arr) + } + /// Is this script "Recommended" according to /// [UAX #31](www.unicode.org/reports/tr31/#Table_Recommended_Scripts)? pub fn is_recommended(self) -> bool {