ankdown icon indicating copy to clipboard operation
ankdown copied to clipboard

UnicodeDecodeError

Open jay-pee opened this issue 5 years ago • 1 comments

When importing the some flashcards with utf8 formatting this error occurs:

Traceback (most recent call last):
  File "c:\Users\Philip\Documents\GitHub\ankdown\ankdown\ankdown.py", line 389, in main
    cards_to_apkg(card_iterator, pkg_arg)
  File "c:\Users\Philip\Documents\GitHub\ankdown\ankdown\ankdown.py", line 340, in cards_to_apkg
    for card in cards:
  File "c:\Users\Philip\Documents\GitHub\ankdown\ankdown\ankdown.py", line 328, in cards_from_dir
    for card in produce_cards(os.path.join(parent_dir, fn)):
  File "c:\Users\Philip\Documents\GitHub\ankdown\ankdown\ankdown.py", line 301, in produce_cards
    for line in f:
  File "C:\Python36\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 3504: character maps to <undefined>

Changing line 297 in ankdown.py to

    with open(filename, "r", encoding="utf8") as f:

helps.

I thought though, that the default import in python is utf8. Should I do a pull request for this little bug?

jay-pee avatar Jul 06 '19 10:07 jay-pee

Weird! Yeah a PR would be great! (I'm traveling so it's a bit tricky to write code)

benwr avatar Jul 06 '19 20:07 benwr