[php-src] PR #23017: ext/intl: Add SpoofChecker::getBidiSkeleton()
| From: | LamentXU123 | Date: | Tue, 04 Aug 2026 10:21:19 +0000 |
| Subject: | [php-src] PR #23017: ext/intl: Add SpoofChecker::getBidiSkeleton() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-37489@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23017
Author: LamentXU123
Follow up #13469. Since we have
SpoofChecker::areBidiConfusable() with all these
constant (UBIDI_LTR, UBIDI_RTL, UBIDI_MIXED and UBIDI_NEUTRAL) it can only determine whether two
strings are visually confusable in a given text direction. Applications that need to detect
confusable identifiers among a large existing set would otherwise need to repeatedly perform
pairwise comparisons using areBidiConfusable().
Now since ICU 74+ and we have SpoofChecker::areBidiConfusable() already, it is
convenient to add the corresponding SpoofChecker::areBidiConfusable() . ICU's bidi
skeleton API transforms an identifier into a skeleton for a given text direction. So it is useful
for larger compares.
e.g.
```php
$checker = new Spoofchecker();
$skeleton = $checker->getBidiSkeleton(
Spoofchecker::LTR,
$identifier
);
if ($skeleton !== false && isset($knownSkeletons[$skeleton])) {
// The identifier may be visually confusable with an existing one.
}
```
The internal API is documented at: https://unicode-org.github.io/icu-docs/apidoc/dev/icu4c/uspoof_8h.html#a62055cfa692b3811341f9699fc8986a0