A PHP internals discussion proposing a new native `grapheme_mask()` function that masks sections of strings by operating on grapheme clusters rather than raw bytes or code points. This enables Unicode-safe masking of sensitive data like credit card numbers, emails, and phone numbers, correctly handling composed characters, diacritical marks, and emoji sequences. The author has a working C prototype based on ICU ubrk and PHPT test cases, and is preparing a formal RFC. A community member also suggests adding a companion `str_mask()` for byte-based masking, which the author agrees to include in the proposal.
Table of contents
grapheme_mask("sepehr@example.com ", " ", 2, -12); // result: se ***@ example.comExample with emoji sequences: grapheme_mask("๐จ๐ฝโ๐ฉโ๐งโ๐ฆ family", "*", 0, 1); // result: * family241 Impressions