def decode(value):
"""Decodes bytes from a base65536 string."""
stream = io.BytesIO()
done = False
for ch in value:
code_point = ord(ch)
b1 = code_point & ((1 << 8) - 1)
try:
b2 = B2[code_point - b1]
except KeyError:
raise ValueError('Invalid base65536 code '
'point: %d' % code_point)
b = int2byte(b1) if b2 == -1 else int2byte(b1) + int2byte(b2)
if len(b) == 1:
if done:
raise ValueError('base65536 sequence '
'continued after final byte')
done = True
stream.write(b)
return stream.getvalue()
评论列表
文章目录