1: #line 188 "utf8.ipk" 2: from array import array 3: 4: # encoding 5: def ucs2le(i): 6: return chr(i & 0xFF)+ chr(i >> 8) 7: 8: def seq_to_ucs2le(a): 9: s = '' 10: for ch in a: s = s + ucs2le(ch) 11: return s 12: 13: # decoding 14: def parse_ucs2le(s, i): 15: return ord(s[i]) + ord(s[i+1]) << 8, i+2 16: 17: def ucs2le_to_array(s): 18: n = len(s) 19: a = array('H',(0,)*n/2) 20: i = 0 21: while i < n: 22: a[i/2],i = parse_ucs2le(s,i) 23: 24: def ucs2le_to_utf8(s): 25: return seq_to_utf8(ucs2le_to_array(s)) 26: