pub struct Windows1252Encoding;
Expand description

Decodes bytes according to the windows1252 code page

use jomini::{Windows1252Encoding, Encoding};

let encoding = Windows1252Encoding::new();
assert_eq!(encoding.decode(b"Common Sense"), "Common Sense");
assert_eq!(
    encoding.decode(b"\xa7GRichard Plantagenet\xa7 ( 2 / 4 / 3 / 0 )"),
    "§GRichard Plantagenet§ ( 2 / 4 / 3 / 0 )"
);
assert_eq!(encoding.decode(br#"Captain \"Joe\" Rogers"#), r#"Captain "Joe" Rogers"#);
assert_eq!(encoding.decode(b"1444.11.11\n"), "1444.11.11");
assert_eq!(encoding.decode(b"\xff"), "ÿ");
assert_eq!(encoding.decode(b"\x8a"), "Š");
assert_eq!(encoding.decode(b"\xfe\xff\xfe\xff\xfe\xff\xfe\xff\xfe\xff"), "þÿþÿþÿþÿþÿ");
assert_eq!(encoding.decode(b"hi\x81\x8a"), "hi\u{81}Š");

Implementations§

Creates a new windows 1252 decoder

Examples found in repository?
src/text/tape.rs (line 164)
163
164
165
    pub fn windows1252_reader(&self) -> ObjectReader<Windows1252Encoding> {
        ObjectReader::new(self, Windows1252Encoding::new())
    }
More examples
Hide additional examples
src/text/de.rs (line 190)
186
187
188
189
190
191
    pub fn from_windows1252_tape<'a, T>(tape: &TextTape<'a>) -> Result<T, Error>
    where
        T: Deserialize<'a>,
    {
        Self::from_encoded_tape(tape, Windows1252Encoding::new())
    }

Static method for decoding windows 1252 data

Examples found in repository?
src/encoding.rs (line 61)
60
61
62
    fn decode<'a>(&self, data: &'a [u8]) -> Cow<'a, str> {
        Windows1252Encoding::decode(data)
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Decodes bytes into a utf-8 compatible string – allocating if necessary

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.