MCPcopy Index your code
hub / github.com/apache/dubbo-python2 / _encode_utf

Method _encode_utf

dubbo/codec/encoder.py:262–281  ·  view source on GitHub ↗

对字符串进行编码,编码格式utf-8 参见方法:com.alibaba.com.caucho.hessian.io.Hessian2Output#printString :param value: :return:

(value)

Source from the content-addressed store, hash-verified

260
261 @staticmethod
262 def _encode_utf(value):
263 """
264 对字符串进行编码,编码格式utf-8
265 参见方法:com.alibaba.com.caucho.hessian.io.Hessian2Output#printString
266 :param value:
267 :return:
268 """
269 result = []
270 for v in value:
271 ch = ord(v)
272 if ch < 0x80:
273 result.append(ch & 0xff)
274 elif ch < 0x800:
275 result.append((0xc0 + ((ch >> 6) & 0x1f)) & 0xff)
276 result.append((0x80 + (ch & 0x3f)) & 0xff)
277 else:
278 result.append((0xe0 + ((ch >> 12) & 0xf)) & 0xff)
279 result.append((0x80 + ((ch >> 6) & 0x3f)) & 0xff)
280 result.append((0x80 + (ch & 0x3f)) & 0xff)
281 return result
282
283 def _encode_str(self, value):
284 """

Callers 1

_encode_strMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected