def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
python类utf_7_decode()的实例源码
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def test_errors(self):
tests = [
('\xe1b', u'\ufffdb'),
('a\xe1b', u'a\ufffdb'),
('a\xe1\xe1b', u'a\ufffd\ufffdb'),
('a+IK', u'a\ufffd'),
('a+IK-b', u'a\ufffdb'),
('a+IK,b', u'a\ufffdb'),
('a+IKx', u'a\u20ac\ufffd'),
('a+IKx-b', u'a\u20ac\ufffdb'),
('a+IKwgr', u'a\u20ac\ufffd'),
('a+IKwgr-b', u'a\u20ac\ufffdb'),
('a+IKwgr,', u'a\u20ac\ufffd'),
('a+IKwgr,-b', u'a\u20ac\ufffd-b'),
('a+IKwgrB', u'a\u20ac\u20ac\ufffd'),
('a+IKwgrB-b', u'a\u20ac\u20ac\ufffdb'),
('a+/,+IKw-b', u'a\ufffd\u20acb'),
('a+//,+IKw-b', u'a\ufffd\u20acb'),
('a+///,+IKw-b', u'a\uffff\ufffd\u20acb'),
('a+////,+IKw-b', u'a\uffff\ufffd\u20acb'),
('a+IKw-b\xe1', u'a\u20acb\ufffd'),
('a+IKw\xe1b', u'a\u20ac\ufffdb'),
]
for raw, expected in tests:
try:
with self.assertRaises(UnicodeDecodeError):
codecs.utf_7_decode(raw, 'strict', True)
self.assertEqual(raw.decode('utf-7', 'replace'), expected)
except:
print 'raw=%r' % raw
raise
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def test_errors(self):
tests = [
('\xe1b', u'\ufffdb'),
('a\xe1b', u'a\ufffdb'),
('a\xe1\xe1b', u'a\ufffd\ufffdb'),
('a+IK', u'a\ufffd'),
('a+IK-b', u'a\ufffdb'),
('a+IK,b', u'a\ufffdb'),
('a+IKx', u'a\u20ac\ufffd'),
('a+IKx-b', u'a\u20ac\ufffdb'),
('a+IKwgr', u'a\u20ac\ufffd'),
('a+IKwgr-b', u'a\u20ac\ufffdb'),
('a+IKwgr,', u'a\u20ac\ufffd'),
('a+IKwgr,-b', u'a\u20ac\ufffd-b'),
('a+IKwgrB', u'a\u20ac\u20ac\ufffd'),
('a+IKwgrB-b', u'a\u20ac\u20ac\ufffdb'),
('a+/,+IKw-b', u'a\ufffd\u20acb'),
('a+//,+IKw-b', u'a\ufffd\u20acb'),
('a+///,+IKw-b', u'a\uffff\ufffd\u20acb'),
('a+////,+IKw-b', u'a\uffff\ufffd\u20acb'),
('a+IKw-b\xe1', u'a\u20acb\ufffd'),
('a+IKw\xe1b', u'a\u20ac\ufffdb'),
]
for raw, expected in tests:
try:
with self.assertRaises(UnicodeDecodeError):
codecs.utf_7_decode(raw, 'strict', True)
self.assertEqual(raw.decode('utf-7', 'replace'), expected)
except:
print 'raw=%r' % raw
raise
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)
def decode(input, errors='strict'):
return codecs.utf_7_decode(input, errors, True)