[Trac-tickets] [The Trac Project] #2186: japanese environment on windows

The Trac Project noreply at edgewall.com
Thu Oct 6 23:54:44 CDT 2005


#2186: japanese environment on windows
----------------------------------------+-----------------------------------
 Reporter:  masaaki.naito at frame-wx.com  |       Owner:  jonas
     Type:  enhancement                 |      Status:  new  
 Priority:  normal                      |   Milestone:       
Component:  general                     |     Version:  0.8.4
 Severity:  normal                      |   Keywords:                              |  
----------------------------------------+-----------------------------------
 I install trac on windows 2000 and use japanese.
 But I can't use japanese in some components.

 In trac-admin, I add component in japanese. but japanese component name
 can't show in component list.

 So I change admin.py and util.py for show japanese.

 Here is patch

 Index: util.py
 ===================================================================
 --- util.py     (revision 2328)
 +++ util.py     (working copy)
 @@ -80,6 +80,22 @@
              u = unicode(text, 'iso-8859-15')
          return u.encode('utf-8')

 +def from_utf8(text, charset='iso-8859-15'):
 +    """Convert a string from UTF-8, assuming the encoding is either
 UTF-8, ISO
 +    Latin-1, or as specified by the optional `charset` parameter."""
 +    try:
 +        # Do nothing if it's already utf-8
 +        u = unicode(text, 'utf-8')
 +        return u.encode(charset)
 +    except UnicodeError:
 +        try:
 +            # Use the user supplied charset if possible
 +            u = unicode(text, charset)
 +        except UnicodeError:
 +            # This should always work
 +            u = unicode(text, 'iso-8859-15')
 +        return u.encode(charset)
 +
  def sql_escape(text):
      """
      Escapes the given string so that it can be safely used in an SQL

-- 
Ticket URL: <http://projects.edgewall.com/trac/ticket/2186>
The Trac Project <http://trac.edgewall.com/>


More information about the Trac-Tickets mailing list