Function encoding_c::encoding_for_label_no_replacement [] [src]

#[no_mangle]
pub unsafe extern "C" fn encoding_for_label_no_replacement(
    label: *const u8,
    label_len: usize
) -> *const Encoding

This function behaves the same as encoding_for_label(), except when encoding_for_label() would return REPLACEMENT_ENCODING, this method returns NULL instead.

This method is useful in scenarios where a fatal error is required upon invalid label, because in those cases the caller typically wishes to treat the labels that map to the replacement encoding as fatal errors, too.

The argument buffer can be in any ASCII-compatible encoding. It is not required to be UTF-8.

label must be non-NULL even if label_len is zero. When label_len is zero, it is OK for label to be something non-dereferencable, such as 0x1. This is required due to Rust's optimization for slices within Option.

Undefined behavior

UB ensues if label and label_len don't designate a valid memory block of if label is NULL.