Skip to content

Commit 4a108c1

Browse files
Merge pull request RustPython#1059 from RustPython/unicodedata
Add initial unicodedata module.
2 parents e05a75c + 13be2cf commit 4a108c1

File tree

5 files changed

+375
-0
lines changed

5 files changed

+375
-0
lines changed

Cargo.lock

Lines changed: 269 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/snippets/unicode_fu.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@
1111
c = *3
1212

1313
assert c == '👋👋👋'
14+
15+
import unicodedata
16+
assert unicodedata.category('a') == 'Ll'
17+
assert unicodedata.category('A') == 'Lu'
18+
assert unicodedata.name('a') == 'LATIN SMALL LETTER A'
19+
assert unicodedata.lookup('LATIN SMALL LETTER A') == 'a'
20+
assert unicodedata.bidirectional('a') == 'L'
21+
assert unicodedata.normalize('NFC', 'bla') == 'bla'

vm/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ indexmap = "1.0.2"
4545
crc = "^1.0.0"
4646
bincode = "1.1.4"
4747
unicode_categories = "0.1.1"
48+
unicode_names2 = "0.2.2"
49+
unic = "0.9.0"
4850
maplit = "1.0"
4951
proc-macro-hack = "0.5"
5052
bitflags = "1.1"

vm/src/stdlib/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ mod thread;
2020
mod time_module;
2121
#[cfg(feature = "rustpython_parser")]
2222
mod tokenize;
23+
mod unicodedata;
2324
mod warnings;
2425
mod weakref;
2526
use std::collections::HashMap;
@@ -56,6 +57,7 @@ pub fn get_module_inits() -> HashMap<String, StdlibInitFunc> {
5657
"time".to_string() => Box::new(time_module::make_module),
5758
"_weakref".to_string() => Box::new(weakref::make_module),
5859
"_imp".to_string() => Box::new(imp::make_module),
60+
"unicodedata".to_string() => Box::new(unicodedata::make_module),
5961
"_warnings".to_string() => Box::new(warnings::make_module),
6062
};
6163

0 commit comments

Comments
 (0)