From: David Mazary Date: Fri, 11 Nov 2011 23:20:29 +0000 (-0500) Subject: Updated qfont_decode to use Xonotic's qfont_table. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9ca1a02569d3e529c64b9ff0f2208f01a280c956;p=xonotic%2Fxonstat.git Updated qfont_decode to use Xonotic's qfont_table. --- diff --git a/xonstat/util.py b/xonstat/util.py index ce94a71..b0b5481 100755 --- a/xonstat/util.py +++ b/xonstat/util.py @@ -1,9 +1,10 @@ import re from datetime import datetime +# Map of special chars to ascii from Quake's console.c. qfont_table = [ '\0', '#', '#', '#', '#', '.', '#', '#', - '#', 9, 10, '#', ' ', 13, '.', '.', + '#', '\t', '\n', '#', ' ', '\r', '.', '.', '[', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '<', '=', '>', ' ', '!', '"', '#', '$', '%', '&', '\'', @@ -40,11 +41,14 @@ qfont_table = [ def qfont_decode(qstr=''): """ - Convert a name from qfont to ascii. - 'qstr' must be a unicode string. + Convert the qfont characters in a string to ascii. """ - by = bytearray(qstr, 'latin_1') - return ''.join([qfont_table[b & 0xff] for b in by]) + chars = [] + for c in qstr: + if c >= u'\ue000' and c <= u'\ue0ff': + c = qfont_table[ord(c) - 0xe000] + chars.append(c) + return ''.join(chars) def strip_colors(str=''):