[−][src]Struct shift_or_euc::Detector
A detector for detecting the character encoding of input on the precondition that the encoding is a Japanese legacy encoding.
Methods
impl Detector
[src]
pub fn new(allow_2022: bool) -> Self
[src]
Instantiates the detector. If allow_2022
is true
the possible
guesses are Shift_JIS, EUC-JP, ISO-2022-JP, and undecided. If
allow_2022
is false
, the possible guesses are Shift_JIS, EUC-JP,
and undecided.
pub fn feed(&mut self, buffer: &[u8], last: bool) -> Option<&'static Encoding>
[src]
Feeds bytes to the detector. If last
is true
the end of the stream
is considered to occur immediately after the end of buffer
.
Otherwise, the stream is expected to continue. buffer
may be empty.
If you're running the detector only on a prefix of a complete
document, do not pass last
as true
after the prefix if the
stream as a whole still contains more content.
Returns Some(encoding_rs::SHIFT_JIS)
if the detector guessed
Shift_JIS. Returns Some(encoding_rs::EUC_JP)
if the detector
guessed EUC-JP. Returns Some(encoding_rs::ISO_2022_JP)
if the
detector guessed ISO-2022-JP (only possible if true
was passed as
allow_2022
when instantiating the detector). Returns None
if the
detector is undecided. If None
is returned even when passing true
as last
, falling back to Shift_JIS is the best guess for Web
purposes.
Do not call again after the method has returned Some(_)
or after
the method has been called with true
as last
.
Panics
If called after the method has returned Some(_)
or after the method
has been called with true
as last
.
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,