/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/xmlwriter.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/xmlwriter.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/thuban/Thuban/Model/xmlwriter.py revision 1886 by jan, Thu Oct 30 09:21:54 2003 UTC branches/WIP-pyshapelib-bramz/Thuban/Model/xmlwriter.py revision 2734 by bramz, Thu Mar 1 12:42:59 2007 UTC
# Line 1  Line 1 
1  # Copyright (c) 2003 by Intevation GmbH  # Copyright (c) 2003, 2005 by Intevation GmbH
2  # Authors:  # Authors:
3  # Jonathan Coles <[email protected]>  # Jonathan Coles <[email protected]>
4  #  #
# Line 14  __version__ = "$Revision$" Line 14  __version__ = "$Revision$"
14  import os  import os
15  from types import UnicodeType  from types import UnicodeType
16    
17    from Thuban import unicode_from_internal
18    
19  #  #
20  # one level of indention  # one level of indention
21  #  #
# Line 119  class XMLWriter: Line 121  class XMLWriter:
121              self.file.write(' %s="%s"' % (self.encode(name),              self.file.write(' %s="%s"' % (self.encode(name),
122                                            self.encode(value)))                                            self.encode(value)))
123    
124      def encode(self, str):      def encode(self, s):
125          """Return an XML-escaped and UTF-8 encoded copy of the string str."""          """Return an XML-escaped and UTF-8 encoded copy of the string s.
   
         esc = escape(str)  
126    
127          if isinstance(esc, UnicodeType):          The parameter must be a string in Thuban's internal string
128              return esc.encode("utf8")          representation or a unicode object.
129          else:          """
130              return unicode(escape(str),'latin1').encode("utf8")          if not isinstance(s, unicode):
131                s = unicode_from_internal(s)
132            return escape(s).encode("utf8")

Legend:
Removed from v.1886  
changed lines
  Added in v.2734

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26