Skip to main content

encode

Function encode 

Source
pub fn encode<D: Dimension>(
    a: &StringArray<D>,
    encoding: &str,
) -> FerrayResult<Vec<Vec<u8>>>
Expand description

Encode each string as UTF-8 bytes, returning a Vec<Vec<u8>> per element.

Equivalent to numpy.strings.encode(arr, encoding="utf-8") for the common UTF-8 case. Other encodings are intentionally not supported — the workspace standardizes on UTF-8 strings, and supporting Latin-1 / CP1252 / Shift-JIS would pull in encoding_rs.

Errors if encoding is not "utf-8" (case-insensitive) and not empty.

§Errors

  • FerrayError::InvalidValue if an unsupported encoding is requested.