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

Method _encode_str

dubbo/codec/encoder.py:283–305  ·  view source on GitHub ↗

对一个字符串进行编码 :param value: :return:

(self, value)

Source from the content-addressed store, hash-verified

281 return result
282
283 def _encode_str(self, value):
284 """
285 对一个字符串进行编码
286 :param value:
287 :return:
288 """
289 result = []
290 # 在进行网络传输操作时一律使用unicode进行操作
291 if isinstance(value, str):
292 value = value.decode('utf-8')
293 length = len(value)
294 if length <= 0x1f:
295 result.append(0x00 + length)
296 elif length <= 0x3ff:
297 result.append(0x30 + (length >> 8))
298 result.append(length)
299 else:
300 result.append(ord('S'))
301 result.append(length >> 8)
302 result.append(length)
303
304 result.extend(self._encode_utf(value))
305 return result
306
307 def _encode_object(self, value):
308 """

Callers 1

_encode_single_valueMethod · 0.95

Calls 1

_encode_utfMethod · 0.95

Tested by

no test coverage detected