Skip to content

Commit

Permalink
#3544 modified code to replace U+00A0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bharath-kandula committed Dec 1, 2023
1 parent 3ea0d19 commit 81df150
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def has_invisible_characters(text):
pattern = re.compile(r'[^\u0000-\u007F]')
pattern = "\u00a0"
return re.search(pattern, text)


Expand Down
18 changes: 4 additions & 14 deletions classification/models/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,21 +1090,11 @@ def process_entry(self, cell: VCDataCell, source: str):
value = cell.value
e_key = cell.e_key
note = cell.note
# unidecode converts non ascii characters to ascii examples Æ Ö

def ensure_string(data):
if isinstance(data, (dict, list)):
data = json.dumps(data)
data = unidecode(data)
data = json.loads(data)
return data
elif isinstance(data, str):
return unidecode(data)
else:
return data

value = ensure_string(value)
note = ensure_string(note)
if value and '\u00a0' in value:
value = value.replace('\u00a0', ' ')
if note and '\u00a0' in note:
note = note.replace('\u00a0', ' ')

if self.lab.external:
cell.validate = False
Expand Down

0 comments on commit 81df150

Please sign in to comment.