Skip to main content

index_fold_char

Function index_fold_char 

Source
pub fn index_fold_char(c: char) -> u8
Expand description

Re-export of the index-folding used internally by QueryGrams::append_char, so callers that buffer already-folded bytes (and feed them via QueryGrams::append_byte) fold identically. Folds a single char to its one-byte index_fold representation.

Equivalent to the per-character output of index_fold: an ASCII char yields its lowercased byte (high bit clear); any other char yields 0x80 | (cp & 0x7F) of its folded code point (high bit set), including a multibyte char that folds to ASCII (e.g. U+212A KELVIN SIGN → 0x80 | b'k').

§Example

use casefold::index_fold_char;
assert_eq!(index_fold_char('A'), b'a');
assert_eq!(index_fold_char('Ü'), 0xFC); // ü → 0x80 | (0xFC & 0x7F)
assert_eq!(index_fold_char('中'), 0x80 | 0x2D);