Modify

Opened 19 years ago

Closed 18 years ago

#192 closed defect (fixed)

FootNoteMacro fails to form footnote hints for UTF-8 strings

Reported by: adem@… Owned by: Alec Thomas
Priority: normal Component: FootNoteMacro
Severity: normal Keywords:
Cc: Trac Release: 0.8

Description

When some non-english text is included into FootNote macro, like this in russian: 1, the macro forms an incorrect hint for the footnote. The important requrement is the text must entered and showed in Unicode (UTF-8) encoding.
The macro trims a footnote text to 16 bytes length, however UTF-8 characters may have not only one-byte length. So the trimmed footnote hint may have not only less than 16 characters, but also the wrong last character, like the footnote above shows.


  1. 1. Это сноска на русском языке

Attachments (0)

Change History (7)

comment:1 Changed 19 years ago by Alec Thomas

Are you using the 0.9? or 0.8? macro?

comment:2 Changed 19 years ago by adem@…

I am using 0.9. Besides, I placed an example here, in the ticked description. It works and clearly shows the problem.

comment:3 Changed 19 years ago by Alec Thomas

Honestly, I have no idea what to do about this. args comes in as ASCII and seemingly any attempt to re-encode it as utf-8 raises an exception. Patches welcome.

comment:4 Changed 18 years ago by re_guzy

Trac Release: 0.8

I am Japanese ,and had the same problem.

I changed the 53rd line of 0.9 as follows.
It works for me.

before

 (id, id, i + 1, wiki_to_oneliner(unescape(v), env)))

after

 (id, id, i + 1, wiki_to_oneliner(v, env)))

comment:5 Changed 18 years ago by betelgeuse

Index: 0.10/FootNote.py
===================================================================
--- 0.10/FootNote.py    (revision 1497)
+++ 0.10/FootNote.py    (working copy)
@@ -33,7 +33,7 @@
        """Un-escapes &, <, > and \""""
        if not text:
                return ''
-       return str(text).replace('&amp;', '&') \
+       return unicode(text).replace('&amp;', '&') \
                .replace('&lt;', '<') \
                .replace('&gt;', '>') \
                .replace('&#34;', '"')
@@ -70,4 +70,4 @@
                        if not existing:
                                hdf.footnotes.append(args)
                full_id = "%i.%i" % (hdf.footnote_set, id)
-               return '<sup><a title="%s" style="font-size: 8pt; font-weight: bold;" id="FootNoteRef%s" href="#FootNote%s">%i</a></sup>' % (args[:16] + "...", full_id, full_id, id)
+       return '<sup><a title="%s..." style="font-size: 8pt; font-weight: bold;" id="FootNoteRef%s" href="#FootNote%s">%i</a></sup>' % (args[:16], full_id, full_id, id)

This fixed the problem in 0.10 for me.

comment:6 in reply to:  5 Changed 18 years ago by anonymous

Replying to betelgeuse:

This fixed the problem in 0.10 for me.

For me too ! Please Commit to Project...

comment:7 Changed 18 years ago by Alec Thomas

Resolution: fixed
Status: newclosed

(In [1733]) Fix for unicode issue. Closes #192, thanks betelgeuse.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Alec Thomas.
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.