Skip to content

Commit

Permalink
Add example executables to get name from character and vice versa (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
progval authored Sep 1, 2023
1 parent 424d0f7 commit 84519ce
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/character.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::env;

fn main() {
let mut arguments = env::args().into_iter();
arguments.next(); // Executable name
for argument in arguments {
match unicode_names2::character(&argument) {
Some(c) => println!("{}", c),
None => println!("{}: no such character", argument),
}
}
}
14 changes: 14 additions & 0 deletions examples/name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::env;

fn main() {
let mut arguments = env::args().into_iter();
arguments.next(); // Executable name
for argument in arguments {
for c in argument.chars() {
match unicode_names2::name(c) {
Some(name) => println!("{}", name),
None => println!("{}: unknown character", argument),
}
}
}
}

0 comments on commit 84519ce

Please sign in to comment.