Logo Search packages:      
Sourcecode: felix version File versions  Download package

ucs4.py

#line 218 "interscript/src/utf8.ipk"
import string

def ucs4(i):
  return
    chr((i >> 24) & 0xFF) +\
    chr((i >> 16) & 0xFF) +\
    chr((i >> 8) & 0xFF) +\
    chr(i & 0xFF)

def seq_to_ucs4(a):
  s = ''
  for ch in a: s = s + ucs4(ch)
  return s

# decoding
def parse_ucs4(s, i):
  return \
    (ord(s[i]) << 24) +\
    (ord(s[i+1]) << 16) +\
    (ord(s[i+2]) << 8)+\
    ord(s[i+3]) , i+4

def ucs4_to_array(s):
  n = len(s)
  a = array('H',(0,)*n/4)
  i = 0
  while i < n:
    a[i/4],i = parse_ucs4(s,i)

def ucs4_to_utf8(s):
  return seq_to_utf8(ucs4_to_array(s))


Generated by  Doxygen 1.6.0   Back to index