-2

I am trying to write a script that will replace all non-english alphabet letters in file names with their English counterparts, is this possible?

1 Answers1

0

If you mean to "deburr" strings, there's a nice, simple-ish recipe for it (for many accented characters anyway) that uses the Unicode NFKD normalization form, then strips everything non-ascii out of it:

>>> import unicodedata
>>> unicodedata.normalize("NFKD", "törkylempijävongahdus").encode("ascii", "ignore").decode()
'torkylempijavongahdus'

For more complex use cases, maybe https://pypi.org/project/transliterate/ is your thing.

AKX
  • 152,115
  • 15
  • 115
  • 172