Struct codepage_strings::Coding[][src]

pub struct Coding(_);

Coding information derived from a Windows code page.

Implementations

impl Coding[src]

pub fn new(cp: u16) -> Result<Self, ConvertError>[src]

Get an encoding for the given code page.

Errors

Will fail with ConvertError::UnknownCodepage or ConvertError::UnsupportedCodepage if an encoding for the given page is unavailable.

pub fn encode<'a, S>(&self, src: S) -> Result<Vec<u8>, ConvertError> where
    S: Into<Cow<'a, str>>, 
[src]

Encode a UTF-8 string into a byte vector according to this encoding.

Errors

Returns ConvertError::StringEncoding if any character cannot be encoded.

pub fn decode<'a>(&self, src: &'a [u8]) -> Result<Cow<'a, str>, ConvertError>[src]

Decode a byte vector into UTF-8 Cow<str> according to this encoding.

Errors

Returns ConvertError::StringDecoding if any character cannot be decoded.

pub fn decode_lossy<'a>(&self, src: &'a [u8]) -> Cow<'a, str>[src]

Decode a byte vector into UTF-8 Cow<str> according to this encoding. Replace any bytes that cannot be encoded with the Unicode “replacement character” (\u{fffd}).

Trait Implementations

impl Clone for Coding[src]

impl Debug for Coding[src]

Auto Trait Implementations

impl RefUnwindSafe for Coding

impl Send for Coding

impl Sync for Coding

impl Unpin for Coding

impl UnwindSafe for Coding

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.