jinja + form + unicode control characters + xml/docx integration jinja + form + unicode control characters + xml/docx integration flask flask

jinja + form + unicode control characters + xml/docx integration


There are tons of the control characters in the unicode. So, basically, you need to remove control characters, which is the one of the category in unicode chars. To do that I recommend you to use unicodedata.category from unicodedata module.

See code below:

import unicodedatadef remove_control_chars(s):    return "".join(ch for ch in s if unicodedata.category(ch)[0] != "C")