wikimedia / equivset
Visually Equivalent Set of UTF-8 Characters
Requires
- php: >=7.4.3
Requires (Dev)
- ext-json: *
- mediawiki/mediawiki-codesniffer: 43.0.0
- mediawiki/mediawiki-phan-config: 0.14.0
- mediawiki/minus-x: 1.1.3
- mikey179/vfsstream: ^1.6
- ockcyp/covers-validator: 1.6.0
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpunit/phpunit: 9.6.16
- rregeer/phpunit-coverage-check: ~0.3.1
- symfony/console: ^3.3 || ^4 || ^5 || ^6
- symfony/var-dumper: ^3.3 || ^4 || ^5 || ^6
README
A mapping of "equivalent" or similar-looking characters (homoglyphs) to prevent spoofing. This is similar to the Unicode Consortium's confusables.txt with some significant differences. Confusables.txt lists character pairs that are visually identical or nearly identical, for example, Latin "A" and Greek "Α" (alpha). This list is much broader, including pairs that merely look similar, for example, "S" and "$". Another difference is that this list only includes letters and punctuation. It does not include symbols, emoji, or graphical elements.
Installation
Using composer: Add the following to the composer.json file for your project:
{ "require": { "wikimedia/equivset": "^1.0.0" } }
And then run composer update
.
Usage
use Wikimedia\Equivset\Equivset; $equivset = new Equivset(); // Normalize a string echo $equivset->normalize( 'sp00f' ); // SPOOF // Get a single character. if ( $equivset->has( 'ɑ' ) ) { $char = $equivset->get( 'ɑ' ); } echo $char; // A // Loop over entire set. foreach ( $equivset as $char => $equiv ) { // Do something. } // Get the entire set. $all = $equivset->all();
Contributing
All changes should be made to ./data/equivset.in
. Then run
bin/console generate-equivset
to generate the JSON, PHP, and plain
text versions of the equivset in ./dist
.
When releasing, update HISTORY.md with git log --format='* %s (%aN)' --topo-order
to consistently list commits.