Edgewall Software

Ticket #4717 (new defect)

Opened 2 years ago

Last modified 5 months ago

wrong table cell width with multibyte in ticket notify

Reported by: xuefer@… Owned by: cboos
Priority: normal Milestone: 0.13
Component: general Version: 0.10.3
Severity: minor Keywords: notification unicode
Cc: shunichi.goto@…

Description

Expected:

Priority:  major                                 |    Component:  Others
Keywords:  tester xxxxxxxxxxxxx                  |     Username:  abc

Unxpected:

Priority:  major                                 |    Component:  Others
Keywords:  tester xxxxxxxxxxxxx                        |     Username:  abc

where xxxxxxxxxxxxx is 7 Chinese characters, in 14 'w' width

Attachments

Change History

  Changed 2 years ago by mgood

  • status changed from new to closed
  • resolution set to wontfix
  • milestone 0.10.4 deleted

So, you're saying that the characters in question are displayed in a font such that each character is wider than an ascii character. For plaintext mail formatting we expect the emails to be displayed in a fixed-width font so that all characters are the same width. If you can, configure your mail client to use a font where the characters will all be the same width. If you can't do that, I'm afraid there's no way to work around that for the plaintext mails. HTML email formatting has been requested, and would enable better formatting with variable-width fonts. See #2625.

  Changed 2 years ago by xuefer@…

  • status changed from closed to reopened
  • resolution wontfix deleted

i'm sure using fixed-width font, and each Chinese character is in the same width as 2 ascii, which IS expected, even u use fixed-width font in html. i agree that using html table can solve the problem, because browser calc the width correctly, but not trac. that's why i ask tach to fix itself, calc the text width, not character count (count of code point)

if u know php, there is  mb_strwidth to do the job.

i'm not familar with python, but it seems there's:

east_asian_width( unichr) 

Returns the east asian width assigned to the Unicode character unichr as string. New in version 2.4. 

One shall never suppose 1 Chinese char is same with as 1 ascii char, in fixed-width font.

  Changed 2 years ago by cboos

  • keywords notification unicode added
  • component changed from ticket system to general
  • severity changed from normal to minor
  • milestone set to 0.12

east_asian_width(unichr) - New in version 2.4

Maybe we can bump the Python requirement in the next version of Trac?

(btw, mgood, tee from itertools is also new in 2.4)

follow-up: ↓ 5   Changed 5 months ago by cboos

  • owner changed from jonas to cboos
  • status changed from reopened to new

Note for self: reuse this code

    from unicodedata import east_asian_width as eaw
    _colwidth = lambda s: sum([eaw(c) in 'WF' and 2 or 1 for c in s])

(from Shun-ichi Goto on Mercurial-devel, used with permission)

where xxxxxxxxxxxxx is 7 Chinese characters, in 14 'w' width

maybe a real example would help...

in reply to: ↑ 4   Changed 5 months ago by Shun-ichi Goto <shunichi.goto@…>

  • cc shunichi.goto@… added

Replying to cboos:

where xxxxxxxxxxxxx is 7 Chinese characters, in 14 'w' width

maybe a real example would help...

For example in Japanese, the text "日本語" (means "Japanese") has 3 characters and occupies 6 column width.

>>> len(u'日本語')
3
>>> _colwidth(u'日本語')
6

Expected (left:

Priority:  major                                 |    Component:  Others
Keywords:  tester 日本語                         |     Username:  abc

Unwanted (extra 3 spaces):

Priority:  major                                 |    Component:  Others
Keywords:  tester 日本語                            |     Username:  abc

follow-up: ↓ 7   Changed 5 months ago by cboos

Note that it doesn't look like browsers are respecting this 3 asian characters -> 6 column width convention, at least when using the default fixed font, as can be seen in the above example. Same goes for Thunderbird when displaying the notification mail for comment:5.

in reply to: ↑ 6   Changed 5 months ago by Shun-ichi Goto <shunichi.goto@…>

Replying to cboos:

Note that it doesn't look like browsers are respecting this 3 asian characters -> 6 column width convention, at least when using the default fixed font, as can be seen in the above example.

I guess it is issue of renderer of application on using multiple fonts (for ASCII and Japanese). For example, if you use MSゴシック (msgothic) font on windows, you will see good looking because it is a fixed-width font having both ASCII and Japanese glyphs.

Add/Change #4717 (wrong table cell width with multibyte in ticket notify)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from cboos. Next status will be 'new'
The owner will change from cboos to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.