Debian Codegraph @

vendor/wikimedia/equivset/README.md

raw
1 # Equivset
2
3 A mapping of "equivalent" or similar-looking characters ([homoglyphs](https://en.wikipedia.org/wiki/Homoglyph)) to prevent spoofing. This is similar to the Unicode Consortium's [confusables.txt](https://www.unicode.org/Public/security/15.1.0/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.
4
5 ## Installation
6 Using composer:
7 Add the following to the composer.json file for your project:
8
9 ```json
10 {
11 "require": {
12 "wikimedia/equivset": "^1.0.0"
13 }
14 }
15 ```
16
17 And then run `composer update`.
18
19 ## Usage
20
21 ```php
22 use Wikimedia\Equivset\Equivset;
23
24 $equivset = new Equivset();
25
26 // Normalize a string
27 echo $equivset->normalize( 'sp00f' ); // SPOOF
28
29 // Get a single character.
30 if ( $equivset->has( 'ɑ' ) ) {
31 $char = $equivset->get( 'ɑ' );
32 }
33 echo $char; // A
34
35 // Loop over entire set.
36 foreach ( $equivset as $char => $equiv ) {
37 // Do something.
38 }
39
40 // Get the entire set.
41 $all = $equivset->all();
42 ```
43
44 ## Contributing
45
46 All changes should be made to `./data/equivset.in`. Then run
47 `bin/console generate-equivset` to generate the JSON, PHP, and plain
48 text versions of the equivset in `./dist`.
49
50 When releasing, update HISTORY.md with `git log --format='* %s (%aN)' --topo-order`
51 to consistently list commits.