petitchevalroux / homoglyph
Replace all homoglyphs with latin characters equivalent, latin homoglyphs are not replaced
v1.0
2019-11-04 20:04 UTC
Requires (Dev)
- phpunit/phpunit: ^5
This package is auto-updated.
Last update: 2024-12-05 07:58:06 UTC
README
Replace all homoglyphs with latin characters equivalent, latin homoglyphs are not replaced.
Install
composer require petitchevalroux/homoglyph
Usage
Replace homoglyphs
<?php echo (new \Pcr\Homoglyph())->replace('аЬсԁеһіјорѕѵѡху'));
Display :
abcdehijopsvwxy
Inspiration and documentation
Datasource : http://www.unicode.org/Public/security/latest/confusables.txt
Import script and idea from : https://github.com/nodeca/unhomoglyph
Supported homoglyphs
- Cyrillic letter (upper and lower case)
- Fullwidth latin (upper and lower case)
- More but not tested yet (feel free to contribute)
Non replaced latin homoglyphs
Following characters are considered as confusing by unicode standard but are not replaced in replace function as they are latin valid characters.
0 => O
I => l
m => rn
1 => l
Fullwidth latin
Fullwidth latin letters (upper and lower case) are replace by the corresponding characters.
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
replacements :
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
Update
The following script allow to update characters-map.php (node is required)
tools/update.php