added remove control characters of an unicode string

This commit is contained in:
Adolfo Gómez García 2021-02-25 13:45:37 +01:00
parent 2968bc7d41
commit 3e07cf53e4

View File

@ -34,6 +34,7 @@ import sys
import os
import re
import datetime
import unicodedata
import typing
from django.utils import formats
@ -167,3 +168,6 @@ def checkValidBasename(baseName: str, length: int = -1) -> None:
if baseName.isdigit():
raise services.Service.ValidationException(ugettext('The machine name can\'t be only numbers'))
def removeControlCharacters(s: str) -> str:
return ''.join(ch for ch in s if unicodedata.category(ch)[0]!="C")