1: #line 218 "utf8.ipk"
2: import string
3:
4: def ucs4(i):
5: return
6: chr((i >> 24) & 0xFF) +\
7: chr((i >> 16) & 0xFF) +\
8: chr((i >> 8) & 0xFF) +\
9: chr(i & 0xFF)
10:
11: def seq_to_ucs4(a):
12: s = ''
13: for ch in a: s = s + ucs4(ch)
14: return s
15:
16:
17: def parse_ucs4(s, i):
18: return \
19: (ord(s[i]) << 24) +\
20: (ord(s[i+1]) << 16) +\
21: (ord(s[i+2]) << 8)+\
22: ord(s[i+3]) , i+4
23:
24: def ucs4_to_array(s):
25: n = len(s)
26: a = array('H',(0,)*n/4)
27: i = 0
28: while i < n:
29: a[i/4],i = parse_ucs4(s,i)
30:
31: def ucs4_to_utf8(s):
32: return seq_to_utf8(ucs4_to_array(s))
33: