Skip to main content

floor_char_boundary

No overview available.

def floor_char_boundary(
text: string,
index: integer
) - > integer

Adjusts a byte index downward to the nearest valid UTF-8 character boundary. This ensures that slicing operations do not split multi-byte characters, which would result in invalid string data.

Parameters

NameTypeDescription
textstringThe source string used to determine character boundaries based on its UTF-8 encoding.
indexintegerThe initial byte offset into the string that may need adjustment to avoid splitting a character.

Returns

TypeDescription
integerThe largest byte index less than or equal to the input index that points to the start of a UTF-8 character.