Lines Matching refs:ucs4
51 def ucs4_to_utf8(ucs4):
54 if ucs4 < 0x80:
55 utf8_rep.append(ucs4)
57 elif ucs4 < 0x800:
58 utf8_rep.append(((ucs4 >> 6) & 0x1F) | 0xC0)
60 elif ucs4 < 0x10000:
61 utf8_rep.append(((ucs4 >> 12) & 0x0F) | 0xE0)
63 elif ucs4 < 0x200000:
64 utf8_rep.append(((ucs4 >> 18) & 0x07) | 0xF0)
66 elif ucs4 < 0x4000000:
67 utf8_rep.append(((ucs4 >> 24) & 0x03) | 0xF8)
69 elif ucs4 < 0x80000000:
70 utf8_rep.append(((ucs4 >> 30) & 0x01) | 0xFC)
76 utf8_rep.append(((ucs4 >> bits) & 0x3F) | 0x80)
81 def utf8_size(ucs4):
82 return len(ucs4_to_utf8(ucs4))