6.6.1. Conversion functions
Here is the module which does the conversions.
Start python section to interscript/encoding/iso8859_1.py[1
/1
]
1: #line 103 "iso8859.ipk"
2:
3: #line 103 "iso8859.ipk"
4: import string
5: #line 103 "iso8859.ipk"
6: import re
7: #line 103 "iso8859.ipk"
8: from array import array
9: #line 103 "iso8859.ipk"
10: import interscript
11: #line 103 "iso8859.ipk"
12: from interscript.encoding.utf8 import utf8
13: #line 103 "iso8859.ipk"
14:
15: #line 103 "iso8859.ipk"
16: tou = array('H')
17: #line 103 "iso8859.ipk"
18: filename = interscript.directory + 'encoding/iso8859-1.dat'
19: #line 103 "iso8859.ipk"
20: f = open(filename,'rb')
21: #line 103 "iso8859.ipk"
22: tou.fromfile(f,256)
23: #line 103 "iso8859.ipk"
24: f.close()
25: #line 103 "iso8859.ipk"
26: del f
27: #line 103 "iso8859.ipk"
28:
29: #line 103 "iso8859.ipk"
30: def iso8859_1_to_unicode(ch):
31: #line 103 "iso8859.ipk"
32: return tou[ch]
33: #line 103 "iso8859.ipk"
34:
35: #line 103 "iso8859.ipk"
36: def iso8859_1_to_utf8(s):
37: #line 103 "iso8859.ipk"
38: u = ''
39: #line 103 "iso8859.ipk"
40: d = tou
41: #line 103 "iso8859.ipk"
42: for ch in s:
43: #line 103 "iso8859.ipk"
44: u = u + utf8(d[ord(ch)])
45: #line 103 "iso8859.ipk"
46: return u
47: #line 103 "iso8859.ipk"
48:
Start python section to interscript/encoding/iso8859_2.py[1
/1
]
1: #line 103 "iso8859.ipk"
2:
3: #line 103 "iso8859.ipk"
4: import string
5: #line 103 "iso8859.ipk"
6: import re
7: #line 103 "iso8859.ipk"
8: from array import array
9: #line 103 "iso8859.ipk"
10: import interscript
11: #line 103 "iso8859.ipk"
12: from interscript.encoding.utf8 import utf8
13: #line 103 "iso8859.ipk"
14:
15: #line 103 "iso8859.ipk"
16: tou = array('H')
17: #line 103 "iso8859.ipk"
18: filename = interscript.directory + 'encoding/iso8859-2.dat'
19: #line 103 "iso8859.ipk"
20: f = open(filename,'rb')
21: #line 103 "iso8859.ipk"
22: tou.fromfile(f,256)
23: #line 103 "iso8859.ipk"
24: f.close()
25: #line 103 "iso8859.ipk"
26: del f
27: #line 103 "iso8859.ipk"
28:
29: #line 103 "iso8859.ipk"
30: def iso8859_2_to_unicode(ch):
31: #line 103 "iso8859.ipk"
32: return tou[ch]
33: #line 103 "iso8859.ipk"
34:
35: #line 103 "iso8859.ipk"
36: def iso8859_2_to_utf8(s):
37: #line 103 "iso8859.ipk"
38: u = ''
39: #line 103 "iso8859.ipk"
40: d = tou
41: #line 103 "iso8859.ipk"
42: for ch in s:
43: #line 103 "iso8859.ipk"
44: u = u + utf8(d[ord(ch)])
45: #line 103 "iso8859.ipk"
46: return u
47: #line 103 "iso8859.ipk"
48:
Start python section to interscript/encoding/iso8859_3.py[1
/1
]
1: #line 103 "iso8859.ipk"
2:
3: #line 103 "iso8859.ipk"
4: import string
5: #line 103 "iso8859.ipk"
6: import re
7: #line 103 "iso8859.ipk"
8: from array import array
9: #line 103 "iso8859.ipk"
10: import interscript
11: #line 103 "iso8859.ipk"
12: from interscript.encoding.utf8 import utf8
13: #line 103 "iso8859.ipk"
14:
15: #line 103 "iso8859.ipk"
16: tou = array('H')
17: #line 103 "iso8859.ipk"
18: filename = interscript.directory + 'encoding/iso8859-3.dat'
19: #line 103 "iso8859.ipk"
20: f = open(filename,'rb')
21: #line 103 "iso8859.ipk"
22: tou.fromfile(f,256)
23: #line 103 "iso8859.ipk"
24: f.close()
25: #line 103 "iso8859.ipk"
26: del f
27: #line 103 "iso8859.ipk"
28:
29: #line 103 "iso8859.ipk"
30: def iso8859_3_to_unicode(ch):
31: #line 103 "iso8859.ipk"
32: return tou[ch]
33: #line 103 "iso8859.ipk"
34:
35: #line 103 "iso8859.ipk"
36: def iso8859_3_to_utf8(s):
37: #line 103 "iso8859.ipk"
38: u = ''
39: #line 103 "iso8859.ipk"
40: d = tou
41: #line 103 "iso8859.ipk"
42: for ch in s:
43: #line 103 "iso8859.ipk"
44: u = u + utf8(d[ord(ch)])
45: #line 103 "iso8859.ipk"
46: return u
47: #line 103 "iso8859.ipk"
48:
Start python section to interscript/encoding/iso8859_4.py[1
/1
]
1: #line 103 "iso8859.ipk"
2:
3: #line 103 "iso8859.ipk"
4: import string
5: #line 103 "iso8859.ipk"
6: import re
7: #line 103 "iso8859.ipk"
8: from array import array
9: #line 103 "iso8859.ipk"
10: import interscript
11: #line 103 "iso8859.ipk"
12: from interscript.encoding.utf8 import utf8
13: #line 103 "iso8859.ipk"
14:
15: #line 103 "iso8859.ipk"
16: tou = array('H')
17: #line 103 "iso8859.ipk"
18: filename = interscript.directory + 'encoding/iso8859-4.dat'
19: #line 103 "iso8859.ipk"
20: f = open(filename,'rb')
21: #line 103 "iso8859.ipk"
22: tou.fromfile(f,256)
23: #line 103 "iso8859.ipk"
24: f.close()
25: #line 103 "iso8859.ipk"
26: del f
27: #line 103 "iso8859.ipk"
28:
29: #line 103 "iso8859.ipk"
30: def iso8859_4_to_unicode(ch):
31: #line 103 "iso8859.ipk"
32: return tou[ch]
33: #line 103 "iso8859.ipk"
34:
35: #line 103 "iso8859.ipk"
36: def iso8859_4_to_utf8(s):
37: #line 103 "iso8859.ipk"
38: u = ''
39: #line 103 "iso8859.ipk"
40: d = tou
41: #line 103 "iso8859.ipk"
42: for ch in s:
43: #line 103 "iso8859.ipk"
44: u = u + utf8(d[ord(ch)])
45: #line 103 "iso8859.ipk"
46: return u
47: #line 103 "iso8859.ipk"
48:
Start python section to interscript/encoding/iso8859_5.py[1
/1
]
1: #line 103 "iso8859.ipk"
2:
3: #line 103 "iso8859.ipk"
4: import string
5: #line 103 "iso8859.ipk"
6: import re
7: #line 103 "iso8859.ipk"
8: from array import array
9: #line 103 "iso8859.ipk"
10: import interscript
11: #line 103 "iso8859.ipk"
12: from interscript.encoding.utf8 import utf8
13: #line 103 "iso8859.ipk"
14:
15: #line 103 "iso8859.ipk"
16: tou = array('H')
17: #line 103 "iso8859.ipk"
18: filename = interscript.directory + 'encoding/iso8859-5.dat'
19: #line 103 "iso8859.ipk"
20: f = open(filename,'rb')
21: #line 103 "iso8859.ipk"
22: tou.fromfile(f,256)
23: #line 103 "iso8859.ipk"
24: f.close()
25: #line 103 "iso8859.ipk"
26: del f
27: #line 103 "iso8859.ipk"
28:
29: #line 103 "iso8859.ipk"
30: def iso8859_5_to_unicode(ch):
31: #line 103 "iso8859.ipk"
32: return tou[ch]
33: #line 103 "iso8859.ipk"
34:
35: #line 103 "iso8859.ipk"
36: def iso8859_5_to_utf8(s):
37: #line 103 "iso8859.ipk"
38: u = ''
39: #line 103 "iso8859.ipk"
40: d = tou
41: #line 103 "iso8859.ipk"
42: for ch in s:
43: #line 103 "iso8859.ipk"
44: u = u + utf8(d[ord(ch)])
45: #line 103 "iso8859.ipk"
46: return u
47: #line 103 "iso8859.ipk"
48:
Start python section to interscript/encoding/iso8859_6.py[1
/1
]
1: #line 103 "iso8859.ipk"
2:
3: #line 103 "iso8859.ipk"
4: import string
5: #line 103 "iso8859.ipk"
6: import re
7: #line 103 "iso8859.ipk"
8: from array import array
9: #line 103 "iso8859.ipk"
10: import interscript
11: #line 103 "iso8859.ipk"
12: from interscript.encoding.utf8 import utf8
13: #line 103 "iso8859.ipk"
14:
15: #line 103 "iso8859.ipk"
16: tou = array('H')
17: #line 103 "iso8859.ipk"
18: filename = interscript.directory + 'encoding/iso8859-6.dat'
19: #line 103 "iso8859.ipk"
20: f = open(filename,'rb')
21: #line 103 "iso8859.ipk"
22: tou.fromfile(f,256)
23: #line 103 "iso8859.ipk"
24: f.close()
25: #line 103 "iso8859.ipk"
26: del f
27: #line 103 "iso8859.ipk"
28:
29: #line 103 "iso8859.ipk"
30: def iso8859_6_to_unicode(ch):
31: #line 103 "iso8859.ipk"
32: return tou[ch]
33: #line 103 "iso8859.ipk"
34:
35: #line 103 "iso8859.ipk"
36: def iso8859_6_to_utf8(s):
37: #line 103 "iso8859.ipk"
38: u = ''
39: #line 103 "iso8859.ipk"
40: d = tou
41: #line 103 "iso8859.ipk"
42: for ch in s:
43: #line 103 "iso8859.ipk"
44: u = u + utf8(d[ord(ch)])
45: #line 103 "iso8859.ipk"
46: return u
47: #line 103 "iso8859.ipk"
48:
Start python section to interscript/encoding/iso8859_7.py[1
/1
]
1: #line 103 "iso8859.ipk"
2:
3: #line 103 "iso8859.ipk"
4: import string
5: #line 103 "iso8859.ipk"
6: import re
7: #line 103 "iso8859.ipk"
8: from array import array
9: #line 103 "iso8859.ipk"
10: import interscript
11: #line 103 "iso8859.ipk"
12: from interscript.encoding.utf8 import utf8
13: #line 103 "iso8859.ipk"
14:
15: #line 103 "iso8859.ipk"
16: tou = array('H')
17: #line 103 "iso8859.ipk"
18: filename = interscript.directory + 'encoding/iso8859-7.dat'
19: #line 103 "iso8859.ipk"
20: f = open(filename,'rb')
21: #line 103 "iso8859.ipk"
22: tou.fromfile(f,256)
23: #line 103 "iso8859.ipk"
24: f.close()
25: #line 103 "iso8859.ipk"
26: del f
27: #line 103 "iso8859.ipk"
28:
29: #line 103 "iso8859.ipk"
30: def iso8859_7_to_unicode(ch):
31: #line 103 "iso8859.ipk"
32: return tou[ch]
33: #line 103 "iso8859.ipk"
34:
35: #line 103 "iso8859.ipk"
36: def iso8859_7_to_utf8(s):
37: #line 103 "iso8859.ipk"
38: u = ''
39: #line 103 "iso8859.ipk"
40: d = tou
41: #line 103 "iso8859.ipk"
42: for ch in s:
43: #line 103 "iso8859.ipk"
44: u = u + utf8(d[ord(ch)])
45: #line 103 "iso8859.ipk"
46: return u
47: #line 103 "iso8859.ipk"
48:
Start python section to interscript/encoding/iso8859_8.py[1
/1
]
1: #line 103 "iso8859.ipk"
2:
3: #line 103 "iso8859.ipk"
4: import string
5: #line 103 "iso8859.ipk"
6: import re
7: #line 103 "iso8859.ipk"
8: from array import array
9: #line 103 "iso8859.ipk"
10: import interscript
11: #line 103 "iso8859.ipk"
12: from interscript.encoding.utf8 import utf8
13: #line 103 "iso8859.ipk"
14:
15: #line 103 "iso8859.ipk"
16: tou = array('H')
17: #line 103 "iso8859.ipk"
18: filename = interscript.directory + 'encoding/iso8859-8.dat'
19: #line 103 "iso8859.ipk"
20: f = open(filename,'rb')
21: #line 103 "iso8859.ipk"
22: tou.fromfile(f,256)
23: #line 103 "iso8859.ipk"
24: f.close()
25: #line 103 "iso8859.ipk"
26: del f
27: #line 103 "iso8859.ipk"
28:
29: #line 103 "iso8859.ipk"
30: def iso8859_8_to_unicode(ch):
31: #line 103 "iso8859.ipk"
32: return tou[ch]
33: #line 103 "iso8859.ipk"
34:
35: #line 103 "iso8859.ipk"
36: def iso8859_8_to_utf8(s):
37: #line 103 "iso8859.ipk"
38: u = ''
39: #line 103 "iso8859.ipk"
40: d = tou
41: #line 103 "iso8859.ipk"
42: for ch in s:
43: #line 103 "iso8859.ipk"
44: u = u + utf8(d[ord(ch)])
45: #line 103 "iso8859.ipk"
46: return u
47: #line 103 "iso8859.ipk"
48:
Start python section to interscript/encoding/iso8859_9.py[1
/1
]
1: #line 103 "iso8859.ipk"
2:
3: #line 103 "iso8859.ipk"
4: import string
5: #line 103 "iso8859.ipk"
6: import re
7: #line 103 "iso8859.ipk"
8: from array import array
9: #line 103 "iso8859.ipk"
10: import interscript
11: #line 103 "iso8859.ipk"
12: from interscript.encoding.utf8 import utf8
13: #line 103 "iso8859.ipk"
14:
15: #line 103 "iso8859.ipk"
16: tou = array('H')
17: #line 103 "iso8859.ipk"
18: filename = interscript.directory + 'encoding/iso8859-9.dat'
19: #line 103 "iso8859.ipk"
20: f = open(filename,'rb')
21: #line 103 "iso8859.ipk"
22: tou.fromfile(f,256)
23: #line 103 "iso8859.ipk"
24: f.close()
25: #line 103 "iso8859.ipk"
26: del f
27: #line 103 "iso8859.ipk"
28:
29: #line 103 "iso8859.ipk"
30: def iso8859_9_to_unicode(ch):
31: #line 103 "iso8859.ipk"
32: return tou[ch]
33: #line 103 "iso8859.ipk"
34:
35: #line 103 "iso8859.ipk"
36: def iso8859_9_to_utf8(s):
37: #line 103 "iso8859.ipk"
38: u = ''
39: #line 103 "iso8859.ipk"
40: d = tou
41: #line 103 "iso8859.ipk"
42: for ch in s:
43: #line 103 "iso8859.ipk"
44: u = u + utf8(d[ord(ch)])
45: #line 103 "iso8859.ipk"
46: return u
47: #line 103 "iso8859.ipk"
48:
Start python section to interscript/encoding/iso8859_14.py[1
/1
]
1: #line 103 "iso8859.ipk"
2:
3: #line 103 "iso8859.ipk"
4: import string
5: #line 103 "iso8859.ipk"
6: import re
7: #line 103 "iso8859.ipk"
8: from array import array
9: #line 103 "iso8859.ipk"
10: import interscript
11: #line 103 "iso8859.ipk"
12: from interscript.encoding.utf8 import utf8
13: #line 103 "iso8859.ipk"
14:
15: #line 103 "iso8859.ipk"
16: tou = array('H')
17: #line 103 "iso8859.ipk"
18: filename = interscript.directory + 'encoding/iso8859-14.dat'
19: #line 103 "iso8859.ipk"
20: f = open(filename,'rb')
21: #line 103 "iso8859.ipk"
22: tou.fromfile(f,256)
23: #line 103 "iso8859.ipk"
24: f.close()
25: #line 103 "iso8859.ipk"
26: del f
27: #line 103 "iso8859.ipk"
28:
29: #line 103 "iso8859.ipk"
30: def iso8859_14_to_unicode(ch):
31: #line 103 "iso8859.ipk"
32: return tou[ch]
33: #line 103 "iso8859.ipk"
34:
35: #line 103 "iso8859.ipk"
36: def iso8859_14_to_utf8(s):
37: #line 103 "iso8859.ipk"
38: u = ''
39: #line 103 "iso8859.ipk"
40: d = tou
41: #line 103 "iso8859.ipk"
42: for ch in s:
43: #line 103 "iso8859.ipk"
44: u = u + utf8(d[ord(ch)])
45: #line 103 "iso8859.ipk"
46: return u
47: #line 103 "iso8859.ipk"
48:
Start python section to interscript/encoding/iso8859_15.py[1
/1
]
1: #line 103 "iso8859.ipk"
2:
3: #line 103 "iso8859.ipk"
4: import string
5: #line 103 "iso8859.ipk"
6: import re
7: #line 103 "iso8859.ipk"
8: from array import array
9: #line 103 "iso8859.ipk"
10: import interscript
11: #line 103 "iso8859.ipk"
12: from interscript.encoding.utf8 import utf8
13: #line 103 "iso8859.ipk"
14:
15: #line 103 "iso8859.ipk"
16: tou = array('H')
17: #line 103 "iso8859.ipk"
18: filename = interscript.directory + 'encoding/iso8859-15.dat'
19: #line 103 "iso8859.ipk"
20: f = open(filename,'rb')
21: #line 103 "iso8859.ipk"
22: tou.fromfile(f,256)
23: #line 103 "iso8859.ipk"
24: f.close()
25: #line 103 "iso8859.ipk"
26: del f
27: #line 103 "iso8859.ipk"
28:
29: #line 103 "iso8859.ipk"
30: def iso8859_15_to_unicode(ch):
31: #line 103 "iso8859.ipk"
32: return tou[ch]
33: #line 103 "iso8859.ipk"
34:
35: #line 103 "iso8859.ipk"
36: def iso8859_15_to_utf8(s):
37: #line 103 "iso8859.ipk"
38: u = ''
39: #line 103 "iso8859.ipk"
40: d = tou
41: #line 103 "iso8859.ipk"
42: for ch in s:
43: #line 103 "iso8859.ipk"
44: u = u + utf8(d[ord(ch)])
45: #line 103 "iso8859.ipk"
46: return u
47: #line 103 "iso8859.ipk"
48:
49: