MCPcopy
hub / github.com/wechatpy/wechatpy / to_binary

Function to_binary

wechatpy/utils.py:110–122  ·  view source on GitHub ↗

Convert value to binary string, 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

108
109
110def to_binary(value, encoding='utf-8'):
111 """Convert value to binary string, default encoding is utf-8
112
113 :param value: Value to be converted
114 :param encoding: Desired encoding
115 """
116 if not value:
117 return b''
118 if isinstance(value, six.binary_type):
119 return value
120 if isinstance(value, six.text_type):
121 return value.encode(encoding)
122 return to_text(value).encode(encoding)
123
124
125def timezone(zone):

Callers 15

__str__Method · 0.90
__repr__Method · 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
__repr__Method · 0.90
__repr__Method · 0.90
add_accountMethod · 0.90
update_accountMethod · 0.90

Calls 2

to_textFunction · 0.85
encodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…