Skip to main content

Homoglyphs – python library for getting homoglyphs and converting to ASCII.

Features

It’s like confusable_homoglyphs but with some features:

  • Load only needed alphabet to memory.

  • Work as quick as possible.

  • Converting to ASCII.

  • More configurable.

  • More stable.

Usage

from homoglyphs import Homoglyphs, STRATEGY_LOAD, STRATEGY_IGNORE, STRATEGY_REMOVE

# detect category
Homoglyphs.detect_category('s')
# 'LATIN'
Homoglyphs.detect_category('ё')
# 'CYRILLIC'
Homoglyphs.detect_category('.')
# 'COMMON'

# get latin combinations (by default initiated only latin alphabet)
Homoglyphs().get_combinations('q')
# ['q', '𝐪', '𝑞', '𝒒', '𝓆', '𝓺', '𝔮', '𝕢', '𝖖', '𝗊', '𝗾', '𝘲', '𝙦', '𝚚']

# load alphabet on init by categories
Homoglyphs(categories=('LATIN', 'COMMON', 'CYRILLIC')).get_combinations('гы')
# ['rы', 'гы', 'ꭇы', 'ꭈы', '𝐫ы', '𝑟ы', '𝒓ы', '𝓇ы', '𝓻ы', '𝔯ы', '𝕣ы', '𝖗ы', '𝗋ы', '𝗿ы', '𝘳ы', '𝙧ы', '𝚛ы']

# load alphabet by demand
Homoglyphs(strategy=STRATEGY_LOAD).get_combinations('гы')
# ['rы', 'гы', 'ꭇы', 'ꭈы', '𝐫ы', '𝑟ы', '𝒓ы', '𝓇ы', '𝓻ы', '𝔯ы', '𝕣ы', '𝖗ы', '𝗋ы', '𝗿ы', '𝘳ы', '𝙧ы', '𝚛ы']

# convert to ASCII
Homoglyphs(strategy=STRATEGY_LOAD).to_ascii('тест')
# ['tect']
Homoglyphs(strategy=STRATEGY_LOAD).to_ascii('ХР123.')  # this is cyrillic "х" and "р"
# ['XP123.', 'XPI23.', 'XPl23.']

# string with chars which can't be converted by default will be ignored
Homoglyphs(strategy=STRATEGY_LOAD).to_ascii('лол')
# []

# you can set strategy for removing not converted non-ASCII chars from result
Homoglyphs(strategy=STRATEGY_LOAD, ascii_strategy=STRATEGY_REMOVE).to_ascii('лол')
# ['o']

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

homoglyphs-1.0.1.tar.gz (7.0 kB view details)

Uploaded Source

File details

Details for the file homoglyphs-1.0.1.tar.gz.

File metadata

  • Download URL: homoglyphs-1.0.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for homoglyphs-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8183950023565addadddf147d27b85f05b9fc922fdef66abe5c2c263890d850b
MD5 d86bc8e5f54dd5600fec31e45a9d3b51
BLAKE2b-256 68cef78414809c97cef853e510eefeb377e242c315c9d1659c06707b75276029

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.4

2 files

2.0.3

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.3.5

2 files

1.3.4

1 file

1.3.3

1 file

1.3.2

1 file

1.3.1

1 file

1.3.0

1 file

1.2.5

1 file

1.2.4

1 file

1.2.3

1 file

1.2.2

1 file

1.2.1

1 file

1.2.0

1 file

This release

1.0.1 This release

1 file

1.0.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page