Opened 8 years ago

Closed 8 years ago

#7184 closed enhancement (fixed)

unable to read special unicode characters

Reported by: Patrick Owned by: Roman Mohr
Priority: normal Component: TracBibPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11


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 to make this work:

<     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)

Attachments (0)

Change History (1)

comment:1 Changed 8 years ago by Roman Mohr

Resolution: fixed
Status: newclosed

r8366, thank you for the patch.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Roman Mohr.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.