2017 © Pedro Peláez
 

library equivset

Visually Equivalent Set of UTF-8 Characters

image

wikimedia/equivset

Visually Equivalent Set of UTF-8 Characters

  • Saturday, July 28, 2018
  • by mediawiki
  • Repository
  • 14 Watchers
  • 0 Stars
  • 2,389 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 31 % Grown

The README.md

Equivset

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., (*1)

Installation

Using composer: Add the following to the composer.json file for your project:, (*2)

{
  "require": {
     "wikimedia/equivset": "^1.0.0"
  }
}

And then run composer update., (*3)

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., (*4)

When releasing, update HISTORY.md with git log --format='* %s (%aN)' --topo-order to consistently list commits., (*5)

The Versions