Registry / serialization / confusables

confusables

JSON →
library1.2.0pypypi✓ verified 24d ago

Confusables is a Python package designed for analyzing and matching words that appear similar but use different Unicode characters. It leverages the official Unicode confusable characters list to detect homoglyphs, which can be useful for applications like identifying malicious fake website names, normalizing text data, or bypassing profanity filters. The library is currently at version 1.2.0 and receives updates as needed, particularly for Unicode character set changes.

pip install confusables
INSTALL
IMPORT
SIG · CONFUSABLES
C
confusables
serializationpythonv1.2.0
Install
1.9s avg
Import
113ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.116s · 21.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.9s · import 0.110s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

is_confusable
from confusables import is_confusable
confusable_characters
from confusables import confusable_characters
confusable_regex
from confusables import confusable_regex
normalize
from confusables import normalize

This quickstart demonstrates the core functionalities: checking if two strings are confusable, generating a regular expression to match confusable variations of a string, and normalizing a string to a list of possible "normal forms" with ASCII priority.

from confusables import is_confusable, confusable_regex, normalize # Check if two strings are confusable print(f"'rover' vs 'ƦỏV3ℛ': {is_confusable('rover', 'ƦỏV3ℛ')}") # Generate a regex for confusable characters regex_pattern = confusable_regex('admin', include_character_padding=True) print(f"Regex for 'admin': {regex_pattern}") # Normalize a string to its confusable ASCII counterparts normalized_forms = normalize('micrоsoft', prioritize_alpha=True) print(f"Normalized forms of 'micrоsoft': {normalized_forms}")
Debug
Known issues
breakingThe `match_subword` option was removed from the `confusable_regex()` function in version 1.0.0. It now behaves as if `match_subword` is always true.
fix
Remove the `match_subword` argument from calls to `confusable_regex()`. The function's behavior now automatically includes subword matching.
affects: >=1.0.0
breakingVersion 1.0.0 updated to Unicode Confusables version 12.1.0, and now matches all Unicode characters with themselves. This may change the set of characters considered confusable compared to older versions.
fix
Review applications relying on specific confusable character sets. The updated Unicode data may result in more comprehensive (or different) matches.
affects: >=1.0.0
gotchaThe definition of 'confusable' is intentionally loose and may become more or less strict in future versions, as it deals with human interpretation. This could subtly alter matching behavior between releases.
fix
Be aware that confusable matching is not an exact science. Regularly test critical use cases with new library versions if strict, consistent matching across versions is required.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'confusables'
The 'confusables' package is not installed in the Python environment or the interpreter cannot locate it in its search path.
fix
Install the package using pip: `pip install confusables`
AttributeError: module 'confusables' has no attribute 'some_method_name'
You are attempting to call a function or access an attribute (e.g., 'some_method_name') that does not exist or is misspelled in the `confusables` module's current API (version 1.2.0). Common functions include `is_confusable`, `confusable_characters`, `confusable_regex`, and `normalize`.
fix
Consult the `confusables` library documentation (PyPI or GitHub) to ensure you are using the correct function names and available attributes. For instance, if you intended to check if two strings are confusable, use `confusables.is_confusable(string1, string2)`.
TypeError: is_confusable() takes 2 positional arguments but 3 were given
This error occurs when a function like `is_confusable` is called with an incorrect number of arguments. For example, `is_confusable` expects exactly two string arguments.
fix
Ensure you are passing the correct number and type of arguments as specified by the function's signature. For `is_confusable`, provide exactly two strings: `from confusables import is_confusable; is_confusable('hello', 'h3ll0')`.
Upgrade
Version history
1.2.0latest on PyPI · released Mar 24, 2021
Audit
Dependencies
pythonrequiredRuntime dependency
python-setuptoolsoptionalBuild dependency, typically handled by pip
Agent activity
28 hits · last 30 days
node
20
OpenAI (training)
1
Resources
confusables — pip install confusables · libregistry