unable to read special unicode characters
|Reported by:||runlevel0||Owned by:||Amfortas|
If you try to use the BibAdd Macro with a UTF-8 encoded file that contains special characters which are encoded with 2 or more Bytes, a UnicodeDecodeError occurs. In my case, I need to use German Umlauts like ä,ö,ü.
A workaround for that is to handle the data as unicode objects from the start. So what I did is to utf-8-decode the string, that was read, into a unicode object. The bibtexparse library and the whole Trac-System handle unicode objects just as well as str objects.
This is the patch I made to tracbib.py to make this work:
191,196c191,192 < try: < # handle all data as unicode objects < u = unicode(string,"utf-8") < entries = extract_entries(u) < except UnicodeDecodeError: < raise TracError("A UnicodeDecodeError occured while loading the data. Try to save the file in UTF-8 encoding.") --- > > entries = extract_entries(string)