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 |
# |
# |
15 |
import xml.sax |
import xml.sax |
16 |
import xml.sax.handler |
import xml.sax.handler |
17 |
from xml.sax import make_parser, ErrorHandler, SAXNotRecognizedException |
from xml.sax import make_parser, ErrorHandler, SAXNotRecognizedException |
18 |
|
from Thuban import internal_from_unicode |
19 |
|
|
20 |
class XMLReader(xml.sax.handler.ContentHandler): |
class XMLReader(xml.sax.handler.ContentHandler): |
21 |
|
|
125 |
getattr(self, method_name[1])(name, qname) |
getattr(self, method_name[1])(name, qname) |
126 |
|
|
127 |
def encode(self, str): |
def encode(self, str): |
128 |
"""Assume that str is in Unicode and encode it into Latin1. |
"""Return the unicode object str in Thuban's internal representation |
129 |
|
|
130 |
If str is None, return None |
If str is None, return None |
131 |
""" |
""" |
132 |
|
if str is None: |
|
if str is not None: |
|
|
return str.encode("latin1") |
|
|
else: |
|
133 |
return None |
return None |
134 |
|
return internal_from_unicode(str) |