[][src]Function shift_or_euc_c::shift_or_euc_detector_feed

#[no_mangle]
pub unsafe extern "C" fn shift_or_euc_detector_feed(
    detector: *mut Detector,
    buffer: *const u8,
    buffer_len: usize,
    last: bool
) -> *const Encoding

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_len may be zero. buffer must not be NULL but may be undereferencable when buffer_len is zero.

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 SHIFT_JIS_ENCODING if the detector guessed Shift_JIS. Returns EUC_JP_ENCODING if the detector guessed EUC-JP. Returns ISO_2022_JP_ENCODING if the detector guessed ISO-2022-JP (only possible if true was passed as allow_2022 when instantiating the detector). Returns NULL if the detector is undecided. If NULL 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 function has returned non-NULL or after the function has been called with true as last.

Panics

If called after the function has returned non-NULL or after the function has been called with true as last.

Undefined Behavior

UB ensues if

  • detector does not point to a detector obtained from shift_or_euc_detector_new but not yet freed with shift_or_euc_detector_free.
  • buffer is NULL.
  • buffer and buffer_len don't designate a range of memory valid for reading.