def test_xml_to_unicode(self):
     tools.eq_(
         converters.xml_to_unicode(self.utf8_entity_escape, 'utf8',
                                   'replace'), self.u_entity)
     tools.eq_(
         converters.xml_to_unicode(self.utf8_attrib_escape, 'utf8',
                                   'replace'), self.u_entity)
     tools.eq_(
         converters.xml_to_unicode(self.ascii_entity_escape, 'ascii',
                                   'replace'), self.u_entity)
     tools.eq_(
         converters.xml_to_unicode(self.ascii_attrib_escape, 'ascii',
                                   'replace'), self.u_entity)
Esempio n. 2
0
printandrep( "xml_str", xml_str, xml_back )
printandrep( "ascii_str", ascii_str, ascii_back )

print SanitationUtils.unicodeToUTF8(None)
print SanitationUtils.utf8ToUnicode(None)
print SanitationUtils.unicodeToXml(None)
print SanitationUtils.xmlToUnicode(None)
print SanitationUtils.unicodeToAscii(None)
print SanitationUtils.asciiToUnicode(None)
print SanitationUtils.coerceUnicode(None)
SanitationUtils.safePrint(None)

print converters.to_bytes(SanitationUtils.coerceUnicode("\xf0\x9f\x91\x8c"))

print converters.to_bytes(SanitationUtils.unicodeToXml("\xf0\x9f\x91\x8c".decode("utf8"), True))
print converters.xml_to_unicode("L")
print converters.xml_to_byte_string("L")
print converters.to_bytes(converters.xml_to_unicode("と"))
print converters.to_bytes(converters.xml_to_byte_string("と", input_encoding="ascii"))
print converters.xml_to_unicode("👌", encoding="ascii")
print converters.xml_to_byte_string("👌", input_encoding="ascii")


map_json = '{"E-mail":"*****@*****.**","Web Site":"http:\/\/technotan.com.au","MYOB Customer Card ID":[""],"MYOB Card ID":[""],"First Name":["Neil \ud83d\udc4c\'&>"],"Surname":["Cunliffe-Williams"],"Contact":["Neil Cunliffe-Williams"],"Company":["Laserphile"],"Address 1":["7 Grosvenor Road"],"Address 2":[""],"City":[""],"Postcode":["6053"],"State":["WA"],"Phone":["0416160912"],"Home Address 1":["7 Grosvenor Road"],"Home Address 2":[""],"Home City":["Bayswater"],"Home Postcode":["6053"],"Home Country":["AU"],"Home State":["WA"],"Role":["ADMIN"],"ABN":["32"],"Business Type":[""],"Birth Date":[""],"Mobile Phone":["+61416160912"],"Fax":[""],"Lead Source":[""],"Referred By":[""]}'

    # unicodeToUTF8(u_str)
    # unicodeToAscii(u_str)
    # unicodeToXml(u_str)
    # utf8ToUnicode(utf8_str)
    # xmlToUnicode(utf8_str)
    # asciiToUnicode(ascii_str)
Esempio n. 3
0
printandrep("ascii_str", ascii_str, ascii_back)

print SanitationUtils.unicode_to_utf8(None)
print SanitationUtils.utf8_to_unicode(None)
print SanitationUtils.unicode_to_xml(None)
print SanitationUtils.xml_to_unicode(None)
print SanitationUtils.unicode_to_ascii(None)
print SanitationUtils.ascii_to_unicode(None)
print SanitationUtils.coerce_unicode(None)
SanitationUtils.safe_print(None)

print converters.to_bytes(SanitationUtils.coerce_unicode("\xf0\x9f\x91\x8c"))

print converters.to_bytes(
    SanitationUtils.unicode_to_xml("\xf0\x9f\x91\x8c".decode("utf8"), True))
print converters.xml_to_unicode("L")
print converters.xml_to_byte_string("L")
print converters.to_bytes(converters.xml_to_unicode("と"))
print converters.to_bytes(
    converters.xml_to_byte_string("と", input_encoding="ascii"))
print converters.xml_to_unicode("👌", encoding="ascii")
print converters.xml_to_byte_string("👌", input_encoding="ascii")

map_json = '{"E-mail":"*****@*****.**","Web Site":"http:\/\/technotan.com.au","MYOB Customer Card ID":[""],"MYOB Card ID":[""],"First Name":["Neil \ud83d\udc4c\'&>"],"Surname":["Cunliffe-Williams"],"Contact":["Neil Cunliffe-Williams"],"Company":["Laserphile"],"Address 1":["7 Grosvenor Road"],"Address 2":[""],"City":[""],"Postcode":["6053"],"State":["WA"],"Phone":["0416160912"],"Home Address 1":["7 Grosvenor Road"],"Home Address 2":[""],"Home City":["Bayswater"],"Home Postcode":["6053"],"Home Country":["AU"],"Home State":["WA"],"Role":["ADMIN"],"ABN":["32"],"Business Type":[""],"Birth Date":[""],"Mobile Phone":["+61416160912"],"Fax":[""],"Lead Source":[""],"Referred By":[""]}'

# unicode_to_utf8(u_str)
# unicode_to_ascii(u_str)
# unicode_to_xml(u_str)
# utf8_to_unicode(utf8_str)
# xml_to_unicode(utf8_str)
# ascii_to_unicode(ascii_str)
Esempio n. 4
0
 def test_xml_to_unicode(self):
     tools.eq_(converters.xml_to_unicode(self.utf8_entity_escape, 'utf8', 'replace'), self.u_entity)
     tools.eq_(converters.xml_to_unicode(self.utf8_attrib_escape, 'utf8', 'replace'), self.u_entity)
     tools.eq_(converters.xml_to_unicode(self.ascii_entity_escape, 'ascii', 'replace'), self.u_entity)
     tools.eq_(converters.xml_to_unicode(self.ascii_attrib_escape, 'ascii', 'replace'), self.u_entity)
Esempio n. 5
0
 def test_xml_to_unicode(self):
     tools.ok_(converters.xml_to_unicode(self.utf8_entity_escape, 'utf8', 'replace') == self.u_entity)
     tools.ok_(converters.xml_to_unicode(self.utf8_attrib_escape, 'utf8', 'replace') == self.u_entity)