From 3447343be037c5a7d3a433f0c9b5a50bd02d4f4e Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Fri, 15 Aug 2025 23:01:24 +0100 Subject: [PATCH 1/2] Add method to return iso15924 tag Signed-off-by: Nico Burns --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index d33f307..580d16c 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 `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 { From 87af9af755a0b7f8ded07ec3dddc98dfb73128ba Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Sat, 16 Aug 2025 00:02:15 +0100 Subject: [PATCH 2/2] Document as big-endian Signed-off-by: Nico Burns --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 580d16c..3872a03 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,7 +38,7 @@ impl Script { Self::inner_from_short_name(input) } - /// The 4-byte iso15924 tag as a `u32` + /// 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)