Modify

Opened 15 years ago

Closed 14 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

Description

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)

Attachments (0)

Change History (1)

comment:1 Changed 14 years ago by Roman Mohr

Resolution: fixed
Status: newclosed

r8366, thank you for the patch.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Roman Mohr.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.