Fix invalid tokenizer issued by #13, bump version to 2.1.1

This commit is contained in:
SuHun Han 2017-04-03 23:05:19 +09:00
parent 5e77f76ead
commit d991f5e3e3
3 changed files with 9 additions and 1 deletions

View File

@ -1,6 +1,6 @@
"""Free Google Translate API for Python. Translates totally free of charge."""
__all__ = 'Translator',
__version_info__ = 2, 1, 0
__version_info__ = 2, 1, 1
__version__ = '.'.join(str(v) for v in __version_info__)

View File

@ -150,6 +150,7 @@ class TokenAcquirer(object):
# append calculated value if l is less than 2048
elif l < 2048:
e.append(l >> 6 | 192)
e.append(l)
# append calculated value if l matches special condition
elif (l & 64512) == 55296 and g + 1 < size and \
ord(text[g + 1]) & 64512 == 56320:

View File

@ -27,6 +27,13 @@ def test_unicode(translator):
assert result.text == u'こんにちは。'
def test_special_chars(translator):
text = u"Copyright © Google"
result = translator.translate(text, src='en', dest='fr')
assert result.text == text
def test_multiple_sentences(translator):
text = u"""Architecturally, the school has a Catholic character.
Atop the Main Building's gold dome is a golden statue of the Virgin Mary.