[][src]Trait codepage_437::ToCp437

pub trait ToCp437<'s, T> {
    fn to_cp437(&'s self, dialect: &Cp437Dialect) -> Result<T, Cp437Error>;
}

Borrow (if possible) Unicode data as cp437 data.

Examples

Good:

let cp437 = [0x4C, 0x6F, 0x63, 0x61, 0x6C, 0x20, 0x6E, 0x65, 0x77, 0x73, 0x20, 0x72, 0x65,
             0x70, 0x6F, 0x72, 0x74, 0x73, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x74, 0x68,
             0x65, 0x20, 0x9E, 0xAB, 0x20, 0x6D, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x20,
             0x41, 0x69, 0x72, 0x20, 0x4D, 0x65, 0x6C, 0x61, 0x6E, 0x65, 0x73, 0x69, 0x91,
             0x20, 0x61, 0x69, 0x72, 0x63, 0x72, 0x61, 0x66, 0x74, 0x20, 0x68, 0x61, 0x73,
             0x20, 0x63, 0x72, 0x61, 0x73, 0x68, 0x65, 0x64, 0x20, 0x74, 0x68, 0x69, 0x73,
             0x20, 0x6D, 0x6F, 0x72, 0x6E, 0x69, 0x6E, 0x67, 0x20, 0x61, 0x72, 0x6F, 0x75,
             0x6E, 0x64, 0x20, 0x39, 0x3A, 0x30, 0x30, 0x61, 0x6D, 0x2E];
let unicode = "Local news reports that the ₧½ million Air Melanesiæ aircraft has crashed this morning around 9:00am.";

assert_eq!(unicode.to_cp437(&CP437_CONTROL), Ok(cp437[..].into()));

Unrepresentable:

// Ż cannot be represented in cp437
let unicode = "Jurek je żurek w żupanie.";

let error = unicode.to_cp437(&CP437_CONTROL).unwrap_err();
assert_eq!(error.representable_up_to, 9);

Required Methods

Do the conversion.

Implementations on Foreign Types

impl<'s> ToCp437<'s, Cow<'s, [u8]>> for str
[src]

Implementors

impl<'s, S: AsRef<str>> ToCp437<'s, Cow<'s, [u8]>> for S
[src]