Convert value to binary string, default encoding is utf-8 :param value: Value to be converted :param encoding: Desired encoding
(value, encoding='utf-8')
| 108 | |
| 109 | |
| 110 | def 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 | |
| 125 | def timezone(zone): |
no test coverage detected
searching dependent graphs…