Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def utf2ucs(utf):
- if utf & 0x80:
- # multibyte
- buf = []
- while not(utf & 0x40):
- buf.append(utf & 0x3f)
- utf >>= 8
- buf.append(utf & (0x3f >> len(buf)))
- ucs = 0
- while buf != []:
- ucs <<= 6
- ucs += buf.pop()
- else:
- # ascii
- ucs = utf
- return unichr(ucs)
Add Comment
Please, Sign In to add comment