Modify

Opened 19 years ago

Closed 11 years ago

#64 closed defect (fixed)

[Patch] utf-8 output not enforced

Reported by: ronin_hun@… Owned by: Steffen Hoffmann
Priority: normal Component: WikiCalendarMacro
Severity: normal Keywords: unicode
Cc: Ryan J Ollos Trac Release: 0.12

Description

Maybe I am missing something, but it seems to me that utf8 output is not enforced, and trac uses utf-8 output only (as of 0.9b2). So if the system's locale encoding is set to e.g.: LATIN2 (iso8859_2), then on the wikipage we see unknown characters represented as "?", because the time.strftime() with %B returns locale specific characters in the locale's encoding.

example: "october" in my language with latin2 (default encoding) is "október" (chr 162, 0xf3 in unicode)

I am not familiar with python, so I could only solve this by replacing the return statement with

    return unicode(table, "iso8859_2").encode("utf8")

but that isn't universal solution, because for Japanese I have to write

    return unicode(table, "shift_jis").encode("utf8")

Attachments (1)

WikiCalendar.py.patch (543 bytes) - added by ronin_hun@… 19 years ago.
proposed patch

Download all attachments as: .zip

Change History (15)

Changed 19 years ago by ronin_hun@…

Attachment: WikiCalendar.py.patch added

proposed patch

comment:1 Changed 19 years ago by ronin_hun@…

Maybe it would be better to use

    locale.nl_langinfo(locale.CODESET)

but as I see that isn't supported in windows (at least in python2.3).

comment:2 Changed 18 years ago by Alec Thomas

milestone: 0.9

Milestone 0.9 deleted

comment:3 Changed 18 years ago by zhigang@…

Trac Release: 0.8
    # prev month link 
    prevMonthURL = thispageURL+'?month=%d&year=%d' % (prevMonth, prevYear) 
    buff.write('<a href="%s">&lt; </a>' % prevMonthURL) 
    # the caption 
    # buff.write(time.strftime('%B %Y', tuple(date)))
    buff.write(time.strftime('%m %Y', tuple(date))) 
    # next month link 
    nextMonthURL = thispageURL+'?month=%d&year=%d' % (nextMonth, nextYear) 
    buff.write('<a href="%s"> &gt;</a>' % nextMonthURL) 
    buff.write('</caption>\n<thead><tr align="center">') 
     
    #for day in calendar.weekheader(2).split():
    weekheaders = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su']
    for day in weekheaders: 
        buff.write('<th scope="col">%s</th>' % day) 
    buff.write('</tr></thead>\n<tbody>\n') 

comment:4 Changed 18 years ago by Matt Good

Can you explain that last block of code? I don't think hardcoding the week days is really the way to go here.

comment:5 Changed 15 years ago by Ryan J Ollos

Summary: utf-8 output not enforced[Patch] utf-8 output not enforced

comment:6 Changed 14 years ago by Ryan J Ollos

Owner: changed from Matt Good to Ryan J Ollos

comment:7 Changed 14 years ago by Ryan J Ollos

Status: newassigned

comment:8 Changed 14 years ago by anonymous

Trac Release: 0.80.11

comment:9 Changed 14 years ago by Steffen Hoffmann

Keywords: unicode added

There has been done considerably efforts to improve the 'sister' plugin WikiTicketCalendarMacro.

With regards to #7564 I'd appreciate, if you could test your issue with the current version of WikiTicketCalendarMacro as well and report back here. I can't make promises, but this might be a big step towards finally solving this issue. Thanks for your patience and for still taking care.

comment:10 Changed 14 years ago by Ryan J Ollos

Cc: Ryan J Ollos added; anonymous removed
Owner: changed from Ryan J Ollos to Steffen Hoffmann
Status: assignednew

comment:11 Changed 13 years ago by Steffen Hoffmann

Ping. Ronin, would you please test the WikiTicketCalendarMacro in current WikiCalendarMacro trunk.

This has a lot of unicode related fixes, and WikiCalendarMacro will be integrated there too very soon, so this would help me a lot to get this issue resolved for you and me. Thank you in advance for taking your time for testing.

comment:12 Changed 13 years ago by ronin_hun@…

Resolution: fixed
Status: newclosed
Trac Release: 0.110.12

Sorry I've been without internet for a while.

Seems fine now after a quick test.

comment:13 Changed 13 years ago by Steffen Hoffmann

Resolution: fixed
Status: closedreopened

Your feedback is most appreciated, even more as it is positive.

Anyway, let's keep this ticket open to remind me, that actual code merge will definitely solve the issues related to (insufficient) Unicode encoding previously spotted with this plugin.

comment:14 Changed 11 years ago by Steffen Hoffmann

Resolution: fixed
Status: reopenedclosed

(In [12842]) WikiCalendarMacro: Releasing current, tested macro package as final product, closes #64, #578, #6636, #7564, #7653, #8818, #9568, #9718 and #9719.

After a long time one of the oldest Trac hacks (see changeset [53]) is united with its ambitious fork WikiTicketCalendarMacro for convenience. While maintaining separate wiki pages for both macros, upstream development continues together in the source:wikicalendarmacro/trunk branch.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Steffen Hoffmann.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.