Edgewall Software

Ticket #2394 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

broken messages on trac-admin

Reported by: trac-ja@… Owned by: jonas
Priority: high Milestone: 0.10
Component: admin/console Version: 0.9
Severity: normal Keywords: unicode
Cc:

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

Change History

Changed 3 years ago by cmlenz

  • milestone changed from 0.9.1 to 0.9.2

Changed 3 years ago by cmlenz

  • milestone changed from 0.9.3 to 0.9.4

Changed 3 years ago by cmlenz

  • keywords unicode added
  • owner changed from daniel to jonas
  • milestone changed from 0.9.4 to 0.11

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.

Changed 3 years ago by eblot

See also #859

Changed 2 years ago by trac-ja@…

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.)

Changed 2 years ago by trac-ja@…

Memo:

I found good library.

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

Changed 2 years ago by jonas

  • status changed from new to assigned

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

Changed 2 years ago by cboos

  • status changed from assigned to closed
  • resolution set to fixed
  • milestone changed from 0.11 to 0.10

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

Add/Change #2394 (broken messages on trac-admin)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.