Skip to content

Instantly share code, notes, and snippets.

@BongoKnight
Created September 4, 2023 14:58
Show Gist options
  • Select an option

  • Save BongoKnight/818d5a40e58ea6fbde6f38620599e9fc to your computer and use it in GitHub Desktop.

Select an option

Save BongoKnight/818d5a40e58ea6fbde6f38620599e9fc to your computer and use it in GitHub Desktop.
Generate UTF8 NFKD text
import unicodedata
import random
unicode_max = 0x10ffff
printable_glyphs = [ chr(x) for x in range(0, unicode_max+1) if chr(x).isprintable()]
alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-.'
dict_alpha = {i:[] for i in alphabet}
for i in printable_glyphs :
normalized_char = unicodedata.normalize("NFKD", i)
if len(normalized_char)==1 and normalized_char in alphabet:
dict_alpha[normalized_char].append(i)
def unormalize_string(string):
unormalized = ""
for letter in string:
if dict_alpha.get(letter):
unormalized += random.choice(dict_alpha.get(letter))
else:
unormalized += letter
return unormalized
unormalize_string("google.com")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment