Skip to content

Conversation

@amcar-dtu
Copy link

Add encoding parameter to file writing function.

Solves the UnicodeEncodeError at write time.

Error Stacktrace
Traceback (most recent call last):
  File "c:\Users\usr\documents\scripts\bib_parser.py", line 103, in <module>
    clean_bib()
    ~~~~~~~~~^^
  File "c:\Users\usr\documents\scripts\bib_parser.py", line 98, in clean_bib
    bibtexparser.write_file(bibtex_file, bibtex_database)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\usr\AppData\Local\miniconda3\Lib\site-packages\bibtexparser\entrypoint.py", line 160, in write_file
    f.write(bibtex_str)
    ~~~~~~~^^^^^^^^^^^^
  File "C:\Users\usr\AppData\Local\miniconda3\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u2010' in position 2731: character maps to <undefined>

Add encoding parameter to file writing function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant