Skip to main content

Module string_extensions

Module string_extensions 

Source
Expand description

Utilities for MRZ-specific string operations: validation, trimming a specific character, and OCR-friendly character replacements commonly used when processing MRZ zones.

These functions are intentionally simple and avoid heap allocations where possible, but return owned String when a transformed string is required.

Functions§

is_valid_mrz_input
Return true if s contains only valid MRZ characters: uppercase A-Z, digits 0-9, or the filler ‘<’.
replace_angle_brackets_with_spaces
Replace MRZ angle brackets ‘<’ with spaces.
replace_similar_digits_with_letters
Replace digits that commonly get misrecognized as letters by OCR:
replace_similar_letters_with_digits
Replace letters that commonly get misrecognized as digits by OCR:
trim_char
Trim leading and trailing occurrences of the single character ch from input. Returns an owned String.