UTF8 error in importing deck

Hello. When I output a deck from Anki Desktop, and send it to friends, they notice an UTF8 error when re-entering. Thank you for your help, how can we solve this problem?

Version 2.1.35 (84dcaa86)
Python 3.8.0 Qt 5.14.2 PyQt 5.14.2

I clicked on Downgrade and got the output again. This time the user encounters this error.

Have you tried Tools>Check Database on both devices?

Hi again. Users get UTF-8 errors when importing collections, even those from AnkiWeb.

What steps should be taken to solve this problem?Thank you for your help.

That could happen if the file has been renamed from .apkg to something else.

1 Like

I did not change the category name. I just shared Ankioutput. Some AnkiWeb files have the same problem.

up :zipper_mouth_face:

Could you paste the exact error message with the UTF-8 error or a screenshot?

If you export your notes as a plain text file and import them again, there should be no error message. Maybe something happened with the text file and its encoding had been changed from UTF-8 to something else.

Maybe instead of exporting and importing as .txt, try to export and import as .apkg.

https://docs.ankiweb.net/#/exporting?id=exporting

2 Likes

Capture1.PNG.e611ebaf55ecf2b9a90beab099ea7095

Thanks for following up. I attached the error image. I also put the sample file that receives the error here.

It’s been caused by the translated string in “فارسی”, “fa_IR”.

#: pylib/anki/importing/__init__.py:14
msgid "Packaged Anki Deck/Collection (*.apkg *.colpkg *.zip)"
msgstr "دسته/مجموعۀ آنکی بسته‌بندی شد (*.apkg*.colpkg*.zip)"

There are no spaces between *.apkg*.colpkg*.zip in the translated version and Anki fallbacks to importing an .apkg file as a .tsv file.

A quick workaround is to switch the interface language to English (Tools - Preferences or Ctrl-P).

But the translated string will need to be updated, i.e.
*.apkg*.colpkg*.zip
replaced with
*.apkg *.colpkg *.zip

4 Likes

Thanks.

Thanks kelciour, good catch.

@mmdj2 would you mind looking into that?

changed it.
I also tested exporting a deck in .apkg format. this is the error that i get:

    Anki 2.1.35 (84dcaa86) Python 3.8.0 Qt 5.14.2 PyQt 5.14.2
    Platform: Windows 10
    Flags: frz=True ao=False sv=2
    Add-ons, last update check: 2020-11-09 11:15:27

    Caught exception:
    Traceback (most recent call last):
      File "anki\notes.py", line 108, in _fieldOrd
    KeyError: 'روی کارت'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "aqt\taskman.py", line 87, in _on_closures_pending
  File "aqt\taskman.py", line 59, in <lambda>
  File "aqt\exporting.py", line 167, in on_done
  File "concurrent\futures\_base.py", line 432, in result
  File "concurrent\futures\_base.py", line 388, in __get_result
  File "concurrent\futures\thread.py", line 57, in run
  File "aqt\exporting.py", line 161, in do_export
  File "anki\exporting.py", line 325, in exportInto
  File "anki\exporting.py", line 339, in doExport
  File "anki\exporting.py", line 382, in _addDummyCollection
  File "anki\notes.py", line 116, in __setitem__
  File "anki\notes.py", line 110, in _fieldOrd
KeyError: 'روی کارت'

I can still export them as text tho.
and also I can import text files too.

Thanks for the report; this is caused by the code assuming the front/back field names in core and desktop will match, which they currently don’t. I’ll try to change the code to cope with this case.

1 Like

I’ve managed a potential fix for what I believe OP was experiencing.
I’m posting my fix, because this should help aide some who are capable of following instructions in Ubuntu, see here:
https://forums.ankiweb.net/t/created-colpkg-invalid-file-format-for-import/10148/3