6.5.5. UCS-4LE

UCS4LE is a four byte direct encodings of of ISO-10646. UCS4LE puts the low byte first. UCS4 is the standard form, the little endian form is provided only to support files of 16 bit words stored in native byte order on little endian machines such as 80x86 boxes.
Start python section to interscript/encoding/ucs4le.py[1 /1 ]
     1: #line 260 "utf8.ipk"
     2: import string
     3: 
     4: def ucs4le(i):
     5:   return
     6:     chr(i & 0xFF) +\
     7:     chr((i >> 8) & 0xFF) +\
     8:     chr((i >> 16) & 0xFF) +\
     9:     chr((i >> 24) & 0xFF)
    10: 
    11: def seq_to_ucs2le(a):
    12:   s = ''
    13:   for ch in a: s = s + ucs4le(ch)
    14:   return s
    15: 
    16: # decoding
    17: def parse_ucs4le(s, i):
    18:   return \
    19:     (ord(s[i+3]) << 24) +\
    20:     (ord(s[i+2]) << 16) +\
    21:     (ord(s[i+1]) << 8) +\
    22:     ord(s[i]) , 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_ucs4le(s,i)
    30: 
    31: def ucs4le_to_utf8(s):
    32:   return seq_to_utf8(ucs4le_to_array(s))
    33: 
    34: 
End python section to interscript/encoding/ucs4le.py[1]