Another attempt to fix VNese bugs with utf-8.

This commit is contained in:
Phuoc Dinh Le 2021-03-31 21:46:42 -05:00 committed by GitHub
parent d8e514911a
commit dd725466e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -139,7 +139,16 @@ def group_test_cases(cases):
def read_head_archive(archive, file):
with archive.open(file) as f:
return f.read(settings.TESTCASE_VISIBLE_LENGTH + 3)
s = f.read(settings.TESTCASE_VISIBLE_LENGTH + 3)
# add this so there are no characters left behind (ex, 'á' = 2 utf-8 chars)
while True:
try:
s.decode('utf-8')
break
except UnicodeDecodeError:
s += f.read(1)
return s
def get_visible_content(data):
data = data or b''