MCPcopy
hub / github.com/wechatpy/wechatpy / to_text

Function to_text

wechatpy/utils.py:95–107  ·  view source on GitHub ↗

Convert value to unicode, default encoding is utf-8 :param value: Value to be converted :param encoding: Desired encoding

(value, encoding='utf-8')

Source from the content-addressed store, hash-verified

93
94
95def to_text(value, encoding='utf-8'):
96 """Convert value to unicode, default encoding is utf-8
97
98 :param value: Value to be converted
99 :param encoding: Desired encoding
100 """
101 if not value:
102 return ''
103 if isinstance(value, six.text_type):
104 return value
105 if isinstance(value, six.binary_type):
106 return value.decode(encoding)
107 return six.text_type(value)
108
109
110def to_binary(value, encoding='utf-8'):

Callers 15

__str__Method · 0.90
__repr__Method · 0.90
__to_textMethod · 0.90
__base64_encodeMethod · 0.90
__base64_decodeMethod · 0.90
__str__Method · 0.90
__repr__Method · 0.90
__str__Method · 0.90
__repr__Method · 0.90
parse_messageFunction · 0.90
__repr__Method · 0.90
__repr__Method · 0.90

Calls 1

decodeMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…