A PHP internals discussion proposing a new native function `grapheme_mask()` to handle masking of sensitive string sections (credit card numbers, emails, phone numbers) in a Unicode-safe way. Current approaches using `substr()`, `strlen()`, `str_repeat()`, and `substr_replace()` are repetitive and error-prone, especially with Unicode edge cases. The proposed function operates on grapheme clusters rather than raw bytes or code points, correctly handling composed characters and emoji sequences. The author is gauging community interest before drafting a formal RFC.
Table of contents
grapheme_mask("sepehr@example.com ", " ", 2, -12); // result: se ***@ example.comExample with emoji sequences: grapheme_mask("๐จ๐ฝโ๐ฉโ๐งโ๐ฆ family", "*", 0, 1); // result: * family88 Impressions