Function convert

Source
pub fn convert(unicode: char) -> Option<u8>
Expand description

Do it.

// Matching unicode code points produce code page 437 code points as `u8`
assert_eq!(u2cp437::convert('☻'), Some(0x02));

// Certain CP437 code points have multiple unicode equivalents
let mu1 = u2cp437::convert('\u{0000B5}'); // "MICRO SIGN"
let mu2 = u2cp437::convert('\u{0003BC}'); // "GREEK SMALL LETTER MU"
assert_eq!(mu1, Some(0xE6));
assert_eq!(mu1, mu2);

// Unicode code points that have no equivalent in CP437, including all control characters but
// the null character, produce nothing
assert_eq!(u2cp437::convert('🤔'), None);
assert_eq!(u2cp437::convert('\n'), None);
assert_eq!(u2cp437::convert('\0'), Some(0x0));