Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -38,6 +38,12 @@ impl Script {
Self::inner_from_short_name(input)
}

/// The 4-byte iso15924 tag as a `u32`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: document as big-endian?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: document as big-endian?

Might be a stupid question, but doesn't u32::from_be_bytes convert to a native endian u32?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... yeah I think so. Perhaps this API ought return [u8; 4] to avoid ambiguity.

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 {
Expand Down
Loading