Cloned DMOJ
This commit is contained in:
parent
f623974b58
commit
49dc9ff10c
513 changed files with 132349 additions and 39 deletions
17
judge/utils/unicode.py
Normal file
17
judge/utils/unicode.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from django.utils import six
|
||||
|
||||
|
||||
def utf8bytes(maybe_text):
|
||||
if maybe_text is None:
|
||||
return
|
||||
if isinstance(maybe_text, six.binary_type):
|
||||
return maybe_text
|
||||
return maybe_text.encode('utf-8')
|
||||
|
||||
|
||||
def utf8text(maybe_bytes, errors='strict'):
|
||||
if maybe_bytes is None:
|
||||
return
|
||||
if isinstance(maybe_bytes, six.text_type):
|
||||
return maybe_bytes
|
||||
return maybe_bytes.decode('utf-8', errors)
|
Loading…
Add table
Add a link
Reference in a new issue