From: Ant Zucaro Date: Mon, 21 Nov 2011 17:41:49 +0000 (-0500) Subject: Decode the funky chars coming from Xonotic. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e8fdb37d3c9d3651a5b418692ac92460e1fd7182;p=xonotic%2Fxonstat.git Decode the funky chars coming from Xonotic. --- diff --git a/xonstat/util.py b/xonstat/util.py index b0b5481..9caf856 100755 --- a/xonstat/util.py +++ b/xonstat/util.py @@ -43,6 +43,9 @@ def qfont_decode(qstr=''): """ Convert the qfont characters in a string to ascii. """ + if qstr is None: + qstr = '' + chars = [] for c in qstr: if c >= u'\ue000' and c <= u'\ue0ff': diff --git a/xonstat/views/submission.py b/xonstat/views/submission.py index 6f776a2..0d5acf2 100755 --- a/xonstat/views/submission.py +++ b/xonstat/views/submission.py @@ -8,7 +8,7 @@ from sqlalchemy import Sequence from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound from xonstat.d0_blind_id import d0_blind_id_verify from xonstat.models import * -from xonstat.util import strip_colors +from xonstat.util import strip_colors, qfont_decode log = logging.getLogger(__name__) @@ -420,9 +420,9 @@ def parse_body(request): (key, value) = line.strip().split(' ', 1) # Server (S) and Nick (n) fields can have international characters. - # We encode these as UTF-8. + # We first convert to normal ASCII, then encode them as UTF-8. if key in 'S' 'n': - value = unicode(value, 'utf-8') + value = qfont_decode(unicode(value, 'utf-8')) if key in 'V' 'T' 'G' 'M' 'S' 'C' 'R' 'W': game_meta[key] = value