I'm working on a tool in maya where at some point, the user can enter a comment on the textField. This comment will later be used as part of the filename that's gonna be saved.
I work in France so the user might use some accentuated characters as "é" or "à".
What i would love would be to just translate them to their non accentuated corresponding character. However I realise this is quite tricky so I would be ok with juste detecting them so I can issue a warning message to the user. I don't want to just strip the incriminated letters as it might result on the comment to be incomprensible.
I know they're some similar questions around here, but they're all on other languages I don't know/understand (such as C++ or php).
Here's what I found so far around the web :
import re
comment = 'something written with some french words and numbers'
if re.match(r'^[A-Za-z0-9_]+$', text):
# issue a warning for the user
This first solution doesn't work because it considers accentuated characters as acceptable.
I found this :
ENGLISH_CHARS = re.compile('[^\W_]', re.IGNORECASE)
ALL_CHARS = re.compile('[^\W_]', re.IGNORECASE | re.UNICODE)
assert len(ENGLISH_CHARS.findall('_àÖÎ_')) == 0
assert len(ALL_CHARS.findall('_àÖÎ_')) == 3
which I thought about using like this :
ENGLISH_CHARS = re.compile('[^\W_]', re.IGNORECASE)
if len(ENGLISH_CHARS .findall(comment)) != len(comment):
# issue a warning for the user
but it only seems to work if the string is encapsulated within underscores.
I'm really sorry if this a duplicate of something I haven't found or understood, but it's been driving me nuts.