Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use stdlib alphabetic and numeric character tables#136

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Manishearth merged 1 commit intounicode-rs:masterfromJules-Bertholet:std-tables
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
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
28 changes: 20 additions & 8 deletionsscripts/unicode.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -232,19 +232,27 @@ def emit_util_mod(f):

#[inline]
fn is_alphabetic(c: char) -> bool {
match c {
'a' ..= 'z' | 'A' ..= 'Z' => true,
c if c > '\x7f' => super::derived_property::Alphabetic(c),
_ => false,
if super::UNICODE_VERSION_U8 == char::UNICODE_VERSION {
c.is_alphabetic()
} else {
match c {
'a' ..= 'z' | 'A' ..= 'Z' => true,
c if c > '\\x7f' => super::derived_property::Alphabetic(c),
_ => false,
}
}
}

#[inline]
fn is_numeric(c: char) -> bool {
match c {
'0' ..= '9' => true,
c if c > '\x7f' => super::general_category::N(c),
_ => false,
if super::UNICODE_VERSION_U8 == char::UNICODE_VERSION {
c.is_numeric()
} else {
match c {
'0' ..= '9' => true,
c if c > '\\x7f' => super::general_category::N(c),
_ => false,
}
}
}

Expand DownExpand Up@@ -388,6 +396,10 @@ def emit_break_module(f, break_table, break_cats, name):
/// The version of [Unicode](http://www.unicode.org/)
/// that this version of unicode-segmentation is based on.
pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
""" % UNICODE_VERSION)

rf.write("""
const UNICODE_VERSION_U8: (u8, u8, u8) = (%s, %s, %s);
""" % UNICODE_VERSION)

# download and parse all the data
Expand Down
26 changes: 18 additions & 8 deletionssrc/tables.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,8 @@
/// that this version of unicode-segmentation is based on.
pub const UNICODE_VERSION: (u64, u64, u64) = (15, 1, 0);

const UNICODE_VERSION_U8: (u8, u8, u8) = (15, 1, 0);

pub mod util {
#[inline]
pub fn bsearch_range_table(c: char, r: &[(char,char)]) -> bool {
Expand All@@ -29,19 +31,27 @@ pub mod util {

#[inline]
fn is_alphabetic(c: char) -> bool {
match c {
'a' ..= 'z' | 'A' ..= 'Z' => true,
c if c > '' => super::derived_property::Alphabetic(c),
_ => false,
if super::UNICODE_VERSION_U8 == char::UNICODE_VERSION {
c.is_alphabetic()
} else {
match c {
'a' ..= 'z' | 'A' ..= 'Z' => true,
c if c > '\x7f' => super::derived_property::Alphabetic(c),
_ => false,
}
}
}

#[inline]
fn is_numeric(c: char) -> bool {
match c {
'0' ..= '9' => true,
c if c > '' => super::general_category::N(c),
_ => false,
if super::UNICODE_VERSION_U8 == char::UNICODE_VERSION {
c.is_numeric()
} else {
match c {
'0' ..= '9' => true,
c if c > '\x7f' => super::general_category::N(c),
_ => false,
}
}
}

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp