Opened 7 years ago

Closed 6 years ago

#7184 closed enhancement (fixed)

unable to read special unicode characters

Reported by: runlevel0 Owned by: Amfortas
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 6 years ago by Amfortas

  • Resolution set to fixed
  • Status changed from new to closed

r8366, thank you for the patch.

Add Comment

Modify Ticket

as closed The owner will remain Amfortas.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.