1.1 --- a/tests/iconv.py Thu Dec 15 01:40:31 2016 +0100
1.2 +++ b/tests/iconv.py Thu Dec 15 16:09:01 2016 +0100
1.3 @@ -1,7 +1,8 @@
1.4 # -*- coding: ISO-8859-1 -*-
1.5
1.6 -from posix.iconv import Converter, EILSEQ
1.7 +from posix.iconv import Converter
1.8
1.9 +only_utf8 = Converter("UTF-8", "UTF-8")
1.10 to_utf8 = Converter("ISO-8859-1", "UTF-8")
1.11 to_utf16 = Converter("ISO-8859-1", "UTF-16")
1.12 from_utf8 = Converter("UTF-8", "ISO-8859-1")
1.13 @@ -21,6 +22,12 @@
1.14 from_utf16.feed(utf16)
1.15 print str(from_utf16) # æøå
1.16
1.17 + # Convert UTF-8 to UTF-8.
1.18 +
1.19 + only_utf8.feed(utf8)
1.20 + utf8_2 = str(only_utf8)
1.21 + print utf8_2 # æøå
1.22 +
1.23 # Convert part of a UTF-16 sequence, then convert the remainder, then obtain
1.24 # the result.
1.25
1.26 @@ -52,11 +59,10 @@
1.27
1.28 try:
1.29 from_utf8.feed(iso) # should raise an exception
1.30 + except UnicodeDecodeError, exc:
1.31 + print "Not UTF-8 input:", exc.value
1.32 except OSError, exc:
1.33 - if exc.value == EILSEQ:
1.34 - print "Not UTF-8 input:", exc.arg
1.35 - else:
1.36 - print "OSError:", exc.value
1.37 + print "OSError:", exc.value
1.38
1.39 print str(from_utf8) #
1.40
1.41 @@ -70,11 +76,10 @@
1.42
1.43 try:
1.44 from_utf8.feed(utf8_2 + iso) # should raise an exception
1.45 + except UnicodeDecodeError, exc:
1.46 + print "Not UTF-8 input:", exc.value
1.47 except OSError, exc:
1.48 - if exc.value == EILSEQ:
1.49 - print "Not UTF-8 input:", exc.arg
1.50 - else:
1.51 - print "OSError:", exc.value
1.52 + print "OSError:", exc.value
1.53
1.54 print str(from_utf8) #
1.55