[][src]Struct shift_or_euc::Detector

pub struct Detector { /* fields omitted */ }

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

impl Send for Detector

impl Sync for Detector

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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