Last active
August 29, 2015 14:09
-
-
Save jbowles/6c04470bd334713bf96a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using the Unicode Names package: http://www.rust-ci.org/huonw/unicode_names/doc/unicode_names/#cargo-enabled | |
//require macros... | |
// in Cargo.toml looks like this: | |
// [dependencies.unicode_names_macros] | |
// git = "https://github.com/huonw/unicode_names" | |
#![feature(phase)] | |
#[phase(plugin)] extern crate unicode_names_macros; | |
//require functions... | |
// in Cargo.toml looks like this: | |
// [dependencies.unicode_names] | |
// git = "https://github.com/huonw/unicode_names" | |
extern crate unicode_names; | |
fn main() { | |
// USE MACROS | |
let x: char = named_char!("snowman"); | |
assert_eq!(x, '☃'); | |
let y: &str = named!("foo bar \\N{BLACK STAR} baz qux"); | |
assert_eq!(y, "foo bar ★ baz qux"); | |
// USE FUNCTIONS | |
println!("☃ is called {}", unicode_names::name('☃')); | |
println!("{} is happy", unicode_names::character("white smiling face")); | |
// Tesing a copy paste from firefox wikipeida page on greek alphabet | |
println!("λ is called {}", unicode_names::name('λ')); | |
println!("{} is STAFF OF AESCULAPIUS", unicode_names::character("AESCULAPIUS, STAFF OF")); | |
} | |
/* -> | |
☃ is called Some(SNOWMAN) | |
λ is called Some(GREEK SMALL LETTER LAMDA) | |
Some(☺) is happy | |
Some(⚕) is STAFF OF AESCULAPIUS | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment