[GIT-PULLS] [php-src] PR #23017: ext/intl: Add SpoofChecker::getBidiSkeleton()
[email protected] (LamentXU123)
| Newsgroups | php.git-pulls |
|---|---|
| Message-ID | <t8wa5acxvHdYwZTheI1rk0NCuSrx4NEpERLds10OU54@main.internal.php.net> |
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