3 """ Compare the output of two codecs.
5 (c) Copyright 2005, Marc-Andre Lemburg (mal@lemburg.com).
7 Licensed to PSF under a Contributor Agreement.
12 def compare_codecs(encoding1
, encoding2
):
14 print 'Comparing encoding/decoding of %r and %r' % (encoding1
, encoding2
)
17 for i
in range(sys
.maxunicode
):
20 c1
= u
.encode(encoding1
)
21 except UnicodeError, reason
:
24 c2
= u
.encode(encoding2
)
25 except UnicodeError, reason
:
28 print ' * encoding mismatch for 0x%04X: %-14r != %r' % \
35 u1
= c
.decode(encoding1
)
39 u2
= c
.decode(encoding2
)
43 print ' * decoding mismatch for 0x%04X: %-14r != %r' % \
48 print 'Found %i mismatches' % mismatch
50 print '-> Codecs are identical.'
52 if __name__
== '__main__':
53 compare_codecs(sys
.argv
[1], sys
.argv
[2])