1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use crate::glif::IntoXML;
use crate::xml::Element;
pub trait Codepoint {
fn display(&self) -> String;
}
impl Codepoint for char {
fn display(&self) -> String {
format!("{:X}", *self as u32)
}
}
impl IntoXML for dyn Codepoint {
fn xml(&self) -> Element {
let mut unicode = xmltree::Element::new("unicode");
unicode.attributes.insert("hex".to_owned(), self.display());
unicode
}
}