open-i18n / rust-unic

UNIC: Unicode and Internationalization Crates for Rust
https://crates.io/crates/unic
Other
234 stars 24 forks source link

Add ucd/name_aliases #251

Closed eyeplum closed 5 years ago

eyeplum commented 5 years ago

Recently I found myself needing to fetch name aliases for a given character and it was not implemented in rust-unic yet. So I implemented it and thought it might be good to merge it back.

Changes

Notes

All of the APIs return a vector of string references because the comments of NameAliases.txt mentions:

Parsers of this data file should take note that the same code point can (and does) occur more than once.

Some unic-inspector examples after the change:

$ unic-inspector \U0010\U000A\U0041\U007F\U0098\U0530
   | U+0010 | DLE                    | Control 
   | U+000A | LF                     | Control 
 A | U+0041 | LATIN CAPITAL LETTER A | Uppercase_Letter 
   | U+007F | DEL                    | Control 
 ˜  | U+0098 | SOS                    | Control 
 ԰ | U+0530 | <none>                 | Unassigned 

Didn't find a GitHub issue for name aliases but #127 might be related.


This change is Reviewable

behnam commented 5 years ago

Yeah, something like that! Risks!

Nit: I think the second fn need a different name, though, since Rust doesn't support that kind of overloading (iirc).

bors[bot] commented 5 years ago

Build succeeded