I am using Python’s re module to censor some text. I have to censor both ASCII and Unicode text, so I need to set re‘s Unicode flag if the text is Unicode. Is there a way that I can detect whether the text is Unicode or not?
I am using Python’s re module to censor some text. I have to censor
Share
ASCII is a subset of Unicode, you don’t have to do anything — unless you have reasons to suspect your text is neither ASCII not Unicode (eg Windows CP 1252 et altri), just go with Unicode by defaut.