pub enum TextEncoding {
StandardEncoding,
MacRomanEncoding,
WinAnsiEncoding,
PdfDocEncoding,
}Variants§
Implementations§
Source§impl TextEncoding
impl TextEncoding
Sourcepub fn encode_strict(&self, text: &str) -> Result<Vec<u8>, char>
pub fn encode_strict(&self, text: &str) -> Result<Vec<u8>, char>
Strict encoding: returns Err(char) for the first codepoint the
encoding cannot represent. Unlike [encode], does NOT silently
substitute ? for unmappable characters — callers that must refuse
to emit corrupt output (e.g. form-field appearance streams) use this
path to produce explicit errors instead of silent garbage.
Contract per encoding:
WinAnsiEncoding: every Unicode codepoint in the Windows-1252 repertoire is representable; every other codepoint fails.MacRomanEncoding: same idea over the Mac Roman repertoire.StandardEncoding/PdfDocEncoding: accepts only the ASCII range0x00..=0x7F(the safe lowest-common-denominator — the lossy UTF-8 passthrough used byencodewould silently produce garbage for non-ASCII here).
pub fn encode(&self, text: &str) -> Vec<u8> ⓘ
pub fn decode(&self, data: &[u8]) -> String
Trait Implementations§
Source§impl Clone for TextEncoding
impl Clone for TextEncoding
Source§fn clone(&self) -> TextEncoding
fn clone(&self) -> TextEncoding
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for TextEncoding
Source§impl Debug for TextEncoding
impl Debug for TextEncoding
Source§impl PartialEq for TextEncoding
impl PartialEq for TextEncoding
impl StructuralPartialEq for TextEncoding
Auto Trait Implementations§
impl Freeze for TextEncoding
impl RefUnwindSafe for TextEncoding
impl Send for TextEncoding
impl Sync for TextEncoding
impl Unpin for TextEncoding
impl UnsafeUnpin for TextEncoding
impl UnwindSafe for TextEncoding
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