[php-src] PR #22605: Implement grapheme_mask() function
| From: | sepehrphpr | Date: | Sun, 05 Jul 2026 11:59:18 +0000 |
| Subject: | [php-src] PR #22605: Implement grapheme_mask() function | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36845@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22605
Author: sepehrphpr
## Description
Adds
grapheme_mask() function to the intl extension for Unicode-aware string masking.
## Features
- Masks a portion of a string based on grapheme clusters (not bytes)
- Supports Unicode grapheme clusters including emoji sequences, combining characters, and ZWJ
sequences
- Proper validation of mask character (must be exactly one grapheme cluster)
- Similar interface to substr() with offset and length
parameters
## Implementation
- New function in ext/intl/grapheme.c
- Helper functions in grapheme_util.h
- Comprehensive tests in ext/intl/tests/grapheme_mask.phpt
## Examples
```php
grapheme_mask("Hello World", "*", 3, 2); // "Hello **rld"
grapheme_mask("سلام دنیا", "#", 2, 3); // "سا###نیا"
grapheme_mask("👨👩👧👦 Family", "•", 0, 1); // "•
Family"
## RFC
Implements RFC: https://wiki.php.net/rfc/grapheme_mask