Struct yore::code_pages::CP1256
source · pub struct CP1256;
Implementations§
source§impl CP1256
impl CP1256
sourcepub fn decode(self, bytes: &[u8]) -> Cow<'_, str>
pub fn decode(self, bytes: &[u8]) -> Cow<'_, str>
Decode CP1256 byte-encoding into UTF-8 string
Examples
use yore::code_pages::CP1256;
assert_eq!(CP1256.decode(&[116, 101, 120, 116]), "text");
sourcepub fn encode(self, s: &str) -> Result<Cow<'_, [u8]>, EncodeError>
pub fn encode(self, s: &str) -> Result<Cow<'_, [u8]>, EncodeError>
Encode UTF-8 string into CP1256 byte-encoding
Undefined characters will result in EncodeError
Examples
use yore::code_pages::CP1256;
use yore::EncodeError;
assert_eq!(CP1256.encode("text").unwrap(), vec![116, 101, 120, 116]);
assert!(matches!(CP1256.encode("text 🦀"), EncodeError));
Trait Implementations§
source§impl CodePage for CP1256
impl CodePage for CP1256
source§fn decode<'a>(&self, bytes: &'a [u8]) -> Result<Cow<'a, str>, DecodeError>
fn decode<'a>(&self, bytes: &'a [u8]) -> Result<Cow<'a, str>, DecodeError>
Decode single-byte encoding into UTF-8 string Read more
source§fn encode<'a>(&self, s: &'a str) -> Result<Cow<'a, [u8]>, EncodeError>
fn encode<'a>(&self, s: &'a str) -> Result<Cow<'a, [u8]>, EncodeError>
Encode UTF-8 string into single-byte encoding Read more
source§fn encode_lossy<'a>(&self, s: &'a str, fallback: u8) -> Cow<'a, [u8]>
fn encode_lossy<'a>(&self, s: &'a str, fallback: u8) -> Cow<'a, [u8]>
Encode UTF-8 string into single-byte encoding Read more
impl Copy for CP1256
Auto Trait Implementations§
impl RefUnwindSafe for CP1256
impl Send for CP1256
impl Sync for CP1256
impl Unpin for CP1256
impl UnwindSafe for CP1256
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more