in dubbo/codec/encoder.py [0:0]
def _encode_utf(value):
"""
对字符串进行编码,编码格式utf-8
参见方法:com.alibaba.com.caucho.hessian.io.Hessian2Output#printString
:param value:
:return:
"""
result = []
for v in value:
ch = ord(v)
if ch < 0x80:
result.append(ch & 0xff)
elif ch < 0x800:
result.append((0xc0 + ((ch >> 6) & 0x1f)) & 0xff)
result.append((0x80 + (ch & 0x3f)) & 0xff)
else:
result.append((0xe0 + ((ch >> 12) & 0xf)) & 0xff)
result.append((0x80 + ((ch >> 6) & 0x3f)) & 0xff)
result.append((0x80 + (ch & 0x3f)) & 0xff)
return result