def encode(self, text, tencoding='utf-8'): if not isinstance(text, unicode): raise Exception('text must be unicode, get %s' % type(text)) utext = stringPartQ2B(text) return utext.encode(tencoding)
def extract_value(xpathnode, encoding='utf-8'): value = ''.join(xpathnode.extract()) return stringPartQ2B(value).encode(encoding)