Function encoding_c::encoding_for_name
[−]
[src]
#[no_mangle]pub unsafe extern fn encoding_for_name(
name: *const u8,
name_len: usize
) -> *const Encoding
If the argument matches exactly (case-sensitively; no whitespace
removal performed) the name of an encoding, returns
const Encoding* representing that encoding. Otherwise panics.
The motivating use case for this function is interoperability with
legacy Gecko code that represents encodings as name string instead of
type-safe Encoding objects. Using this function for other purposes is
most likely the wrong thing to do.
name must be non-NULL even if name_len is zero. When name_len
is zero, it is OK for name to be something non-dereferencable,
such as 0x1. This is required due to Rust's optimization for slices
within Option.
Panics
Panics if the argument is not the name of an encoding.
Undefined behavior
UB ensues if name and name_len don't designate a valid memory block
of if name is NULL.