Mercurial > hg > orthanc
comparison Resources/EncodingTests.py @ 1091:a66224eec125
encoding tests
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 05 Aug 2014 12:28:55 +0200 |
parents | e494ceb8d763 |
children | 60cc0ee61edb |
comparison
equal
deleted
inserted
replaced
1090:e494ceb8d763 | 1091:a66224eec125 |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 | 3 |
4 source = u'éäöòДΘĝדصķћ๛ネİ' | 4 source = u'TestéäöòДΘĝדصķћ๛ネİ' |
5 | 5 |
6 encodings = { | 6 encodings = { |
7 'UTF-8' : 'Utf8', | 7 'UTF-8' : 'Utf8', |
8 'ASCII' : 'Ascii', | 8 'ASCII' : 'Ascii', |
9 'ISO-8859-1' : 'Latin1', | 9 'ISO-8859-1' : 'Latin1', |
15 'ISO-8859-6' : 'Arabic', | 15 'ISO-8859-6' : 'Arabic', |
16 'ISO-8859-7' : 'Greek', | 16 'ISO-8859-7' : 'Greek', |
17 'ISO-8859-8' : 'Hebrew', | 17 'ISO-8859-8' : 'Hebrew', |
18 'TIS-620' : 'Thai', | 18 'TIS-620' : 'Thai', |
19 'SHIFT-JIS' : 'Japanese', | 19 'SHIFT-JIS' : 'Japanese', |
20 #'GB18030' : 'Chinese', | 20 #'GB18030' : 'Chinese', # Done manually below (*) |
21 } | 21 } |
22 | 22 |
23 #from encodings.aliases import aliases | 23 #from encodings.aliases import aliases |
24 #for a, b in aliases.iteritems(): | 24 #for a, b in aliases.iteritems(): |
25 # print '%s : %s' % (a, b) | 25 # print '%s : %s' % (a, b) |
42 s = source.encode(encoding, 'ignore') | 42 s = source.encode(encoding, 'ignore') |
43 encoded.append(ToArray(s)) | 43 encoded.append(ToArray(s)) |
44 expected.append(ToArray(s.decode(encoding).encode('utf-8'))) | 44 expected.append(ToArray(s.decode(encoding).encode('utf-8'))) |
45 | 45 |
46 | 46 |
47 # https://en.wikipedia.org/wiki/GB_18030#Technical_details | 47 # https://en.wikipedia.org/wiki/GB_18030#Technical_details (*) |
48 l.append('::Orthanc::Encoding_Chinese') | 48 l.append('::Orthanc::Encoding_Chinese') |
49 expected.append(ToArray('Þßàáâã')) | 49 expected.append(ToArray('Þßàáâã')) |
50 encoded.append('"\\x81\\x30\\x89\\x37\\x81\\x30\\x89\\x38\\xA8\\xA4\\xA8\\xA2\\x81\\x30\\x89\\x39\\x81\\x30\\x8A\\x30"') | 50 encoded.append('"\\x81\\x30\\x89\\x37\\x81\\x30\\x89\\x38\\xA8\\xA4\\xA8\\xA2\\x81\\x30\\x89\\x39\\x81\\x30\\x8A\\x30"') |
51 | 51 |
52 | 52 |