MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / utf8_unpack_chunk

Function utf8_unpack_chunk

rust/stringzilla.rs:1258–1278  ·  view source on GitHub ↗

Unpacks a UTF-8 byte sequence into UTF-32 codepoints. This function decodes UTF-8 encoded text into individual Unicode codepoints, storing them in a u32 array. It processes as many complete characters as possible given the input and output buffer sizes. # Arguments `text`: The UTF-8 encoded byte slice to decode. `runes`: Output buffer to store decoded codepoints. # Returns A tuple `(bytes_con

(text: &[u8], runes: &mut [u32])

Source from the content-addressed store, hash-verified

1256/// ```
1257///
1258pub fn utf8_unpack_chunk(text: &[u8], runes: &mut [u32]) -> (usize, usize) {
1259 let mut runes_unpacked: usize = 0;
1260
1261 let result = unsafe {
1262 sz_utf8_unpack_chunk(
1263 text.as_ptr() as *const c_void,
1264 text.len(),
1265 runes.as_mut_ptr(),
1266 runes.len(),
1267 &mut runes_unpacked,
1268 )
1269 };
1270
1271 let bytes_consumed = if result.is_null() {
1272 0
1273 } else {
1274 unsafe { result.offset_from(text.as_ptr() as *const c_void) as usize }
1275 };
1276
1277 (bytes_consumed, runes_unpacked)
1278}
1279
1280/// Computes a 64-bit AES-based hash value for a given byte slice `text`.
1281/// This function is designed to provide a high-quality hash value for use in

Callers

nothing calls this directly

Calls 3

as_ptrMethod · 0.80
lenMethod · 0.80
sz_utf8_unpack_chunkFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…