10000 Merge pull request #4 from crlf0710/various_changes · unicode-rs/unicode-script@5b65d2f · GitHub
[go: up one dir, main page]

Skip to content

Commit 5b65d2f

Browse files
authored
Merge pull request #4 from crlf0710/various_changes
Various changes
2 parents 4a8cb11 + f0f956f commit 5b65d2f

File tree

3 files changed

+1040
-968
lines changed

3 files changed

+1040
-968
lines changed

scripts/unicode.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
# except according to those terms.
1212

1313
# This script uses the following Unicode tables:
14-
# - DerivedCoreProperties.txt
15-
# - auxiliary/GraphemeBreakProperty.txt
16-
# - auxiliary/WordBreakProperty.txt
17-
# - ReadMe.txt
18-
# - UnicodeData.txt
14+
# - PropertyValueAliases.txt
15+
# - ScriptExtensions.txt
16+
# - Scripts.txt
1917
#
2018
# Since this should not require frequent updates, we just store this
2119
# out-of-line and check the unicode.rs file into git.
@@ -39,7 +37,7 @@
3937
use super::ScriptExtension;
4038
'''
4139

42-
UNICODE_VERSION = (12, 0, 0)
40+
UNICODE_VERSION = (13, 0, 0)
4341

4442
UNICODE_VERSION_NUMBER = "%s.%s.%s" %UNICODE_VERSION
4543

src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ impl ScriptExtension {
193193
(self.first == 0) & (self.second == 0) & (self.third == 0)
194194
}
195195

196+
/// Returns the number of scripts in the script extension
197+
pub fn len(self) -> usize {
198+
if self.is_common_or_inherited() {
199+
1
200+
} else {
201+
(self.first.count_ones() + self.second.count_ones() + self.third.count_ones()) as usize
202+
}
203+
}
204+
196205
/// Intersect this `ScriptExtension` with another `ScriptExtension`. Produces `Unknown` if things
197206
/// do not intersect. This is equivalent to [`ScriptExtension::intersection`] but it stores the result
198207
/// in `self`
@@ -257,9 +266,9 @@ impl ScriptExtension {
257266
ext
258267
}
259268

260-
/// Iterate over the scripts in this string
269+
/// Iterate over the scripts in this script extension
261270
///
262-
/// Will never yeild Script::Unknown
271+
/// Will never yield Script::Unknown
263272
pub fn iter(self) -> ScriptIterator {
264273
ScriptIterator { ext: self }
265274
}

0 commit comments

Comments
 (0)
0