Modify

Opened 4 years ago

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

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 4 years ago by Amfortas

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

r8366, thank you for the patch.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.