adjust order in _encode_char to prioritise ASCII; ' ' is used in the character list to flag characters with no known UTF-8 code, better not encode as these

This commit is contained in:
Michael Billington 2016-09-11 21:06:44 +10:00
parent 9a65945fcd
commit 83f926758c
1 changed files with 2 additions and 2 deletions

View File

@ -132,10 +132,10 @@ class Encoder(object):
:param char: char to encode
:param charmap: dictionary for mapping characters in this code page
"""
if char in charmap:
return charmap[char]
if ord(char) < 128:
return ord(char)
if char in charmap:
return charmap[char]
return ord('?')
def encode(self, text, encoding, defaultchar='?'):