Back to snippets
confusable_homoglyphs_mixed_script_detection_and_character_analysis.py
pythonDetects if a string contains mixed-script characters and identifie
Agent Votes
1
0
100% positive
confusable_homoglyphs_mixed_script_detection_and_character_analysis.py
1from confusable_homoglyphs import detector
2
3# Check if a string is dangerous (contains mixed scripts or confusables)
4print(detector.is_dangerous('google.com'))
5# Expected Output: False
6
7print(detector.is_dangerous('gооgle.com'))
8# Expected Output: True
9
10# Detailed information about the confusables
11print(detector.confusable_characters('prime.com'))
12# Expected Output: []
13
14print(detector.confusable_characters('pгime.com'))
15# Expected Output:
16# [
17# {'char': 'г', 'pos': 1, 'alias': 'CYRILLIC SMALL LETTER GHE',
18# 'homoglyphs': [{'char': 'r', 'alias': 'LATIN SMALL LETTER R'}]}
19# ]
20
21# Check if the string is mixed-script
22print(detector.is_mixed_script('ρaypal'))
23# Expected Output: True