Opened 19 years ago
Closed 19 years ago
#2394 closed defect (fixed)
broken messages on trac-admin
Reported by: | Owned by: | Jonas Borgström | |
---|---|---|---|
Priority: | high | Milestone: | 0.10 |
Component: | admin/console | Version: | 0.9 |
Severity: | normal | Keywords: | unicode |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
trac-admin
shows broken messages on non UTF-8 console
(ex. CMD.EXE
). The inputs are normally done, invalid-cases
are only a display.
There is very simple cause. Even what charset the console is,
display trac-admin
with UTF-8.
When this patch is applied, it will improve:
-
trac/scripts/admin.py
25 25 import time 26 26 import traceback 27 27 import urllib 28 import locale 28 29 29 30 import trac 30 31 from trac import perm, util, db_default … … 198 199 return [a for a in words if a.startswith (text)] 199 200 200 201 def print_listing(self, headers, data, sep=' ', decor=True): 202 (cons_locale, cons_charset) = locale.getdefaultlocale() 201 203 ldata = list(data) 202 204 if decor: 203 205 ldata.insert(0, headers) … … 218 220 sp = sep 219 221 if cnum + 1 == ncols: 220 222 sp = '' # No separator after last column 223 if ldata[rnum][cnum]: 224 if cons_charset: 225 pdata = unicode(ldata[rnum][cnum], 'utf-8').encode(cons_charset) 226 else: 227 pdata = ldata[rnum][cnum] 228 else: 229 pdata = '' 221 230 print ('%%-%ds%s' % (colw[cnum], sp)) \ 222 % ( ldata[rnum][cnum] or ''),231 % (pdata), 223 232 print 224 233 if rnum == 0 and decor: 225 234 print ''.join(['-' for x in
Attachments (0)
Change History (8)
comment:1 by , 19 years ago
Milestone: | 0.9.1 → 0.9.2 |
---|
comment:2 by , 19 years ago
Milestone: | 0.9.3 → 0.9.4 |
---|
comment:3 by , 19 years ago
Keywords: | unicode added |
---|---|
Milestone: | 0.9.4 → 0.11 |
Owner: | changed from | to
comment:5 by , 19 years ago
Excuse me that the answer is delayed.
I think, this problem has three faces:
- Character-based wrap/cut.
- Byte-based wrap/cut escaping multi-byte charcter's border, for RSS output. (<description> element allows lines shorter than 80 bytes.)
- Griph-based wrap/cut, for
trac-admin
's display and other monospace displays.
1 resolves by unicode branch.
2 is not pointed out, yet.
3 is pointed by cmlenz on this ticket.
Python's string object knows number of characters (by length of unicode string) and number of bytes (by length of utf-8 or other encoded string), but doesn't know colums by griph-size.
Later version-2.4, Python has unicodedata.east_asian_width()
method implements East Asian Width
that is Unicode's Specification. It's not impletemted Python-2.3
before. However, we can use that to resolve this problem
(w/ dismissing Python-2.3 environments… ).
(Note: docutils-0.4 uses above.)
I will try to write patches, but I need time to think/write, because these are very large and difficult features. Do you know more simple methods? (I don't know Python very much.)
comment:7 by , 19 years ago
Status: | new → assigned |
---|
I've fixed this in the unicode branch. It's not in trunk yet.
comment:8 by , 19 years ago
Milestone: | 0.11 → 0.10 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
This must have been fixed by r3024. Please test and reopen if there are still issues with this.
There are still problems with incorrect column width for strings with multi-byte characters, as we're counting bytes in
print_listing()
, not characters. IMHO we should tackle this on the unicode branch.