Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#2394 closed defect (fixed)

broken messages on trac-admin

Reported by: trac-ja@… 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

     
    2525import time
    2626import traceback
    2727import urllib
     28import locale
    2829
    2930import trac
    3031from trac import perm, util, db_default
     
    198199        return [a for a in words if a.startswith (text)]
    199200
    200201    def print_listing(self, headers, data, sep=' ', decor=True):
     202        (cons_locale, cons_charset) = locale.getdefaultlocale()
    201203        ldata = list(data)
    202204        if decor:
    203205            ldata.insert(0, headers)
     
    218220                    sp = sep
    219221                if cnum + 1 == ncols:
    220222                    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 = ''
    221230                print ('%%-%ds%s' % (colw[cnum], sp)) \
    222                       % (ldata[rnum][cnum] or ''),
     231                      % (pdata),
    223232            print
    224233            if rnum == 0 and decor:
    225234                print ''.join(['-' for x in

Attachments (0)

Change History (8)

comment:1 by Christopher Lenz, 18 years ago

Milestone: 0.9.10.9.2

comment:2 by Christopher Lenz, 18 years ago

Milestone: 0.9.30.9.4

comment:3 by Christopher Lenz, 18 years ago

Keywords: unicode added
Milestone: 0.9.40.11
Owner: changed from daniel to Jonas Borgström

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.

comment:4 by Emmanuel Blot, 18 years ago

See also #859

comment:5 by trac-ja@…, 18 years ago

Excuse me that the answer is delayed.

I think, this problem has three faces:

  1. Character-based wrap/cut.
  2. Byte-based wrap/cut escaping multi-byte charcter's border, for RSS output. (<description> element allows lines shorter than 80 bytes.)
  3. 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:6 by trac-ja@…, 18 years ago

Memo:

I found good library.

http://city.plala.jp/download/eawidth/ .

comment:7 by Jonas Borgström, 18 years ago

Status: newassigned

I've fixed this in the unicode branch. It's not in trunk yet.

comment:8 by Christian Boos, 18 years ago

Milestone: 0.110.10
Resolution: fixed
Status: assignedclosed

This must have been fixed by r3024. Please test and reopen if there are still issues with this.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.