[−][src]Function chardetng_c::chardetng_encoding_detector_feed
#[no_mangle] pub unsafe extern "C" fn chardetng_encoding_detector_feed(
detector: *mut EncodingDetector,
buffer: *const u8,
buffer_len: usize,
last: bool
) -> bool
Inform the detector of a chunk of input.
The byte stream is represented as a sequence of calls to this function such that the concatenation of the arguments to this function form the byte stream. It does not matter how the application chooses to chunk the stream. It is OK to call this function with a zero-length byte slice.
The end of the stream is indicated by calling this function with
last
set to true
. In that case, the end of the stream is
considered to occur after the last byte of the buffer
(which
may be zero-length) passed in the same call. Once this function
has been called with last
set to true
this function must not
be called again.
If you want to perform detection on just the prefix of a longer
stream, do not pass last=true
after the prefix if the stream
actually still continues.
Returns true
if after processing buffer
the stream has
contained at least one non-ASCII byte and false
if only
ASCII has been seen so far.
Panics
If this function has previously been called with last
set to true
.
Undefined Behavior
UB ensues if
detector
does not point to a detector obtained fromchardetng_detector_new
but not yet freed withchardetng_detector_free
.buffer
isNULL
. (It can be a bogus pointer whenbuffer_len
is 0.)- ,buffer_len
is non-zero and
bufferand
buffer_len` don't designate a range of memory valid for reading.