Skip to content

Add method to return ISO15924 tag as u32 #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 15, 2025

Conversation

nicoburns
Copy link
Contributor

@nicoburns nicoburns commented Aug 15, 2025

The short_name is always 4 ascii bytes, so it's convenient to be able to access it as a u32.

src/lib.rs Outdated
@@ -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.

Signed-off-by: Nico Burns <[email protected]>
@Manishearth Manishearth merged commit 1ad9b49 into unicode-rs:master Aug 15, 2025
3 checks passed
@nicoburns
Copy link
Contributor Author

@Manishearth Any chance of a release with these changes?

github-merge-queue bot pushed a commit to servo/servo that referenced this pull request Aug 18, 2025
…t for harfbuzz (#38704)

Replaces a big match statement with a call to `unicode_script`'s
`Script::short_name` method which has the same big match statement. We
special case `Script::Unknown` because the `short_name` method returns
empty string for that variant, but harfbuzz represents it with `Zzzz`.

EDIT: `Zzzz` seems to be in the spec so I've sent a PR to
`unicode_script` to use it:
unicode-rs/unicode-script#23
EDIT: And unicode-rs/unicode-script#24 which
would allow us to remove this method entirely.

Signed-off-by: Nico Burns <[email protected]>
PotatoCP pushed a commit to PotatoCP/servo that referenced this pull request Aug 20, 2025
…t for harfbuzz (servo#38704)

Replaces a big match statement with a call to `unicode_script`'s
`Script::short_name` method which has the same big match statement. We
special case `Script::Unknown` because the `short_name` method returns
empty string for that variant, but harfbuzz represents it with `Zzzz`.

EDIT: `Zzzz` seems to be in the spec so I've sent a PR to
`unicode_script` to use it:
unicode-rs/unicode-script#23
EDIT: And unicode-rs/unicode-script#24 which
would allow us to remove this method entirely.

Signed-off-by: Nico Burns <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants