Skip to content

Commit

Permalink
removal of non-utf characters
Browse files Browse the repository at this point in the history
  • Loading branch information
daveight committed Aug 26, 2024
1 parent 996f455 commit 6f07853
Show file tree
Hide file tree
Showing 46 changed files with 156 additions and 147 deletions.
11 changes: 9 additions & 2 deletions build_decks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright: Daveight and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import argparse
import errno
import os
from unidecode import unidecode
from argparse import ArgumentParser


Expand Down Expand Up @@ -33,6 +33,12 @@ def get_file_content(path: str):
f.close()


def replace_non_utf_chars(description: str) -> str:
# Replace non-UTF-8 characters with their closest UTF-8 equivalent
clean_description = unidecode(description)
return clean_description


SOLUTION_SECTIONS = [['header', ''], ['java', 'Java'], ['cpp', 'C++'], ['js', 'JavaScript'], ['python', 'Python']]
parser = ArgumentParser()
parser.add_argument('--debug', dest='debug', action='store_true')
Expand All @@ -53,6 +59,7 @@ def get_file_content(path: str):

name = name.replace('.tsv', '')
description = get_file_content(f'src/{deck_name}/descriptions/' + name)
description = replace_non_utf_chars(description)
if description is None:
print('can\'t find description for ' + name)
continue
Expand All @@ -71,7 +78,7 @@ def get_file_content(path: str):
for section in SOLUTION_SECTIONS:
txt = get_file_content(f'src/{deck_name}/solutions/{section[0]}/{name}')
if txt is None:
print(f'can\'t find {section[0]} solution for {name}')
# print(f'can\'t find {section[0]} solution for {name}')
continue
if section[1]:
solution += '### ' + section[1] + '\n'
Expand Down
16 changes: 8 additions & 8 deletions dist/epi-arrays.csv

Large diffs are not rendered by default.

Loading

0 comments on commit 6f07853

Please sign in to comment.