Edgewall Software

Opened 17 years ago

Closed 17 years ago

#119 closed defect (invalid)

XML template incorrectly un-escapes non-breaking spaces

Reported by: ianp@… Owned by: cmlenz
Priority: minor Milestone: 0.5
Component: Serialization Version: 0.4
Keywords: Cc:

Description (last modified by cmlenz)

When an XML template contains non-breaking space entities ( ) the generated output replaces these with this character ( ).

Pasting this into a terminal on my Mac reports it as \302\240 but I'm not too sure whet this means as 0x12E 0xF0 doesn't correspond to a Unicode code-point.

Other entities (such as AMPERSAND - &) are output correctly.

I'm attaching the template that I used and the function that generates it is here:

    def gen_file(path, name, tmpl, rsrc):
        """
        Generate a file for a resource from a template.
        
        path: the path tuple
        name: the base name of the file to generate
        tmpl: the template file to use
        rsrc: the resource to use
        """
        if not path: path = (u'')
        path = u'/'.join(path)
        stream = loader.load(tmpl).generate(project = project, resource = rsrc)
        filename = join(output_dir, path, name) + suffix
        f = open(normpath(filename), 'w')
        f.write(stream.render())
        f.close()

Attachments (1)

Folders.xhtml (582 bytes) - added by ianp@… 17 years ago.
XML Template

Download all attachments as: .zip

Change History (4)

Changed 17 years ago by ianp@…

XML Template

comment:1 Changed 17 years ago by cmlenz

  • Description modified (diff)

(fix description formatting)

comment:2 Changed 17 years ago by cmlenz

Well, this should be the UTF-8 encoding of a non-breaking space unicode character, which is represented by the bytestring \xc2\xa0. I'm not sure what the OS X terminal makes out of this. Are you implying that the space inserted isn't actually rendered as non-breaking by the browser?

comment:3 Changed 17 years ago by ianp@…

  • Resolution set to invalid
  • Status changed from new to closed

I've checked into it some more and the funky rendering that I was seeing was caused by a different problem (passing in a string instead of a single element tuple - damn you, trailing comma!)

Cheers, and thanks for the quick response!

Ian.

Note: See TracTickets for help on using tickets.