Struct codepage_strings::Coding [−][src]
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]
S: Into<Cow<'a, str>>,
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,