Fix Unicode encoding issue
This commit is contained in:
parent
ad34e39a4a
commit
46ac456477
|
@ -143,13 +143,13 @@ class Unicode:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def decode (s):
|
def decode (s):
|
||||||
return '<' + ','.join ("U+%04X" % ord (u) for u in unicode (s, 'utf8')) + '>'
|
return '<' + u','.join ("U+%04X" % ord (u) for u in unicode (s, 'utf-8')).encode ('utf-8') + '>'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def encode (s):
|
def encode (s):
|
||||||
s = re.sub (r"[<+>\\uU]", " ", s)
|
s = re.sub (r"[<+>,\\uU\n ]", " ", s)
|
||||||
s = re.sub (r"0[xX]", " ", s)
|
s = re.sub (r"0[xX]", " ", s)
|
||||||
return u''.join (unichr (int (x, 16)) for x in re.split ('[, \n]', s) if len (x))
|
return u''.join (unichr (int (x, 16)) for x in s.split (' ') if len (x)).encode ('utf-8')
|
||||||
|
|
||||||
shorthands = {
|
shorthands = {
|
||||||
"ZERO WIDTH NON-JOINER": "ZWNJ",
|
"ZERO WIDTH NON-JOINER": "ZWNJ",
|
||||||
|
@ -186,7 +186,7 @@ class Unicode:
|
||||||
s = re.sub (r"[<+>\\uU]", " ", s)
|
s = re.sub (r"[<+>\\uU]", " ", s)
|
||||||
s = re.sub (r"0[xX]", " ", s)
|
s = re.sub (r"0[xX]", " ", s)
|
||||||
s = [unichr (int (x, 16)) for x in re.split ('[, \n]', s) if len (x)]
|
s = [unichr (int (x, 16)) for x in re.split ('[, \n]', s) if len (x)]
|
||||||
return ' + '.join (Unicode.pretty_name (x) for x in s)
|
return u' + '.join (Unicode.pretty_name (x) for x in s).encode ('utf-8')
|
||||||
|
|
||||||
|
|
||||||
class FileHelprs:
|
class FileHelprs:
|
||||||
|
|
Loading…
Reference in New Issue