NAME

Unicode::Confuse - Identify and replace Unicode confusables

SYNOPSIS

use Unicode::Confuse;

VERSION

This documents version 0.04 of Unicode-Confuse corresponding to git commit 4e58610c66c63629292f9c4035c6de40696241f3 released on Thu Apr 29 09:05:45 2021 +0900.

This Perl module incorporates Unicode Security Mechanisms for UTS #39 version 13.0.0 dated 2020-02-13, 01:38:49 GMT, copyright © 2020 Unicode®, Inc.. For terms of use, see http://www.unicode.org/terms_of_use.html

DESCRIPTION

This module offers functions for dealing with Unicode "confusables", characters which look similar to one another but are represented by different Unicode code points.

FUNCTIONS

canonical

my $canonical = canonical ($c);

If $c is a confusable, give the canonical form of $c. If not, returns the undefined value.

confusable

if (confusable ($c)) {
    # do something.
}

Is $c confusable, yes or no? This matches $c against the large regex in Unicode::Confuse::Regex.

DEPENDENCIES

File::Slurper

This is used by the parsing module Unicode::Confuse::Parse. You don't actually need to use the parsing module to use this module with the built-in version of the data.

JSON::Parse

This is used to parse the JSON-formatted file of confusables distributed with the module.

BUGS

Unicode specifications

This does not even attempt to replicate the Unicode requirements for software for handling confusables. In other words, this Perl module makes no claim whatsoever to be "An implementation claiming conformance to this specification" as described in the text of the "Unicode Consortium specification".

Data quality

The data in the Unicode confusables file is of mixed quality, with nearly identical or indistinguishable characters muddled together with things which are clearly quite different from one another.

SEE ALSO

In this distribution

The script make-confusables.pl, available only in the github repository, makes the data files for this Perl distribution.

Unicode::Confuse::Parse is used to parse the data file (confusables.txt). It is used by make-confusables.pl.

Unicode::Confuse::Regex is generated by make-confusables.pl. It matches all confusables.

The unexported variable $Unicode::Confuse::data contains the complete confusable data. $data->{confusables} contains a map from confusables to the canonical format, and $data->{reverse} contains a map from the canonical form to an array containing the corresponding set of confusables, which may have only one member.

Unicode Consortium information

Unicode Consortium specification

See http://www.unicode.org/reports/tr39 for the Unicode Consortium specification.

Unicode data files

The following links point to the latest data files:

The data used by this module
The same data in a different format

AUTHOR

Ben Bullock, <bkb@cpan.org>

COPYRIGHT & LICENCE

This package and associated files are copyright (C) 2021 Ben Bullock.

You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence.