Skip to main content

Crate zerobox_utils_string

Crate zerobox_utils_string 

Source

Functions§

approx_bytes_for_tokens
approx_token_count
approx_tokens_from_byte_count
find_uuids
Find all UUIDs in a string.
normalize_markdown_hash_location_suffix
Convert a markdown-style #L.. location suffix into a terminal-friendly :line[:column][-line[:column]] suffix.
sanitize_metric_tag_value
Sanitize a tag value to comply with metric tag validation rules: only ASCII alphanumeric, ‘.’, ‘_’, ‘-’, and ‘/’ are allowed.
take_bytes_at_char_boundary
to_ascii_json_string
Serialize JSON while escaping non-ASCII string content as \uXXXX.
truncate_middle_chars
Truncate a string to max_bytes using a character-count marker.
truncate_middle_with_token_budget
Truncate the middle of a UTF-8 string to at most max_tokens approximate tokens, preserving the beginning and the end. Returns the possibly truncated string and Some(original_token_count) if truncation occurred; otherwise returns the original string and None.