Opened 20 years ago
Closed 19 years ago
#192 closed defect (fixed)
FootNoteMacro fails to form footnote hints for UTF-8 strings
| Reported by: | 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. Это сноска на русском языке
Attachments (0)
Change History (7)
comment:1 Changed 20 years ago by
comment:2 Changed 20 years ago by
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 20 years ago by
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 19 years ago by
| 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 follow-up: 6 Changed 19 years ago by
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('&', '&') \
+ return unicode(text).replace('&', '&') \
.replace('<', '<') \
.replace('>', '>') \
.replace('"', '"')
@@ -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 Changed 19 years ago by
Replying to betelgeuse:
This fixed the problem in 0.10 for me.
For me too ! Please Commit to Project...
comment:7 Changed 19 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
(In [1733]) Fix for unicode issue. Closes #192, thanks betelgeuse.



Are you using the 0.9? or 0.8? macro?