Skip to content

Commit 1ad9b49

Browse files
authored
Merge pull request #24 from nicoburns/iso15924-tag
Add method to return ISO15924 tag as `u32`
2 parents 323e8df + 87af9af commit 1ad9b49

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
mod tables;
88

9-
use core::convert::TryFrom;
9+
use core::convert::{TryFrom, TryInto};
1010
use core::fmt;
1111
use core::u64;
1212
pub use tables::script_extensions;
@@ -38,6 +38,12 @@ impl Script {
3838
Self::inner_from_short_name(input)
3939
}
4040

41+
/// The 4-byte iso15924 tag as a big-endian `u32`
42+
pub fn as_iso15924_tag(self) -> u32 {
43+
let arr: [u8; 4] = self.inner_short_name().as_bytes().try_into().unwrap();
44+
u32::from_be_bytes(arr)
45+
}
46+
4147
/// Is this script "Recommended" according to
4248
/// [UAX #31](www.unicode.org/reports/tr31/#Table_Recommended_Scripts)?
4349
pub fn is_recommended(self) -> bool {

0 commit comments

Comments
 (0)