finalion / WordQuery

word fast-querying addon for anki
https://ankiweb.net/shared/info/775418273
GNU General Public License v3.0
291 stars 61 forks source link

UnicodeDecodeError, ordinal not in range #48

Closed hosseinalipour closed 7 years ago

hosseinalipour commented 7 years ago

when querying in this dictionary a UnicodeDecodeError occurs! https://drive.google.com/open?id=0B7BA9BhXUAEwcmNYaGJLN3UzaEU


Traceback (most recent call last):
  File "C:\Users\landlord\AppData\Roaming\Anki2\addons\wquery\query.py", line 314, in run
    result = self.query(service_field, word)
  File "C:\Users\landlord\AppData\Roaming\Anki2\addons\wquery\query.py", line 326, in query
    return self.service.active(service_field, word)
  File "C:\Users\landlord\AppData\Roaming\Anki2\addons\wquery\service\base.py", line 162, in active
    result = each[1]()
  File "C:\Users\landlord\AppData\Roaming\Anki2\addons\wquery\service\base.py", line 59, in _deco
    res = fld_func(cls, *args, **kwargs)
  File "C:\Users\landlord\AppData\Roaming\Anki2\addons\wquery\service\base.py", line 276, in fld_whole
    html = self.get_html()
  File "C:\Users\landlord\AppData\Roaming\Anki2\addons\wquery\service\base.py", line 285, in get_html
    result = self.builder.mdx_lookup(self.word.encode('utf-8'))
  File "C:\Users\landlord\AppData\Roaming\Anki2\addons\wquery\libs\mdict\mdict_query.py", line 315, in mdx_lookup
    self.get_mdx_by_index(mdx_file, index))
  File "C:\Users\landlord\AppData\Roaming\Anki2\addons\wquery\libs\mdict\mdict_query.py", line 279, in get_mdx_by_index
    record = self._replace_stylesheet(record)
  File "C:\Users\landlord\AppData\Roaming\Anki2\addons\wquery\libs\mdict\mdict_query.py", line 123, in _replace_stylesheet
    style[0] + p.rstrip() + style[1] + '\r\n'
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd9 in position 4: ordinal not in range(128)
finalion commented 7 years ago

@HosseinAlipour Fixed. Thanks a lot for your test and feedback!