+ The same as fold if cte_type is 7bit, except that the returned value is bytes. If cte_type is 8bit, non-ASCII binary data is converted back into bytes. Headers with binary data are not refolded, regardless of the refold_header setting, since there is no wa
(self, name, value)
| 184 | return self._fold(name, value, refold_binary=True) |
| 185 | |
| 186 | def fold_binary(self, name, value): |
| 187 | """+ |
| 188 | The same as fold if cte_type is 7bit, except that the returned value is |
| 189 | bytes. |
| 190 | |
| 191 | If cte_type is 8bit, non-ASCII binary data is converted back into |
| 192 | bytes. Headers with binary data are not refolded, regardless of the |
| 193 | refold_header setting, since there is no way to know whether the binary |
| 194 | data consists of single byte characters or multibyte characters. |
| 195 | |
| 196 | If utf8 is true, headers are encoded to utf8, otherwise to ascii with |
| 197 | non-ASCII unicode rendered as encoded words. |
| 198 | |
| 199 | """ |
| 200 | folded = self._fold(name, value, refold_binary=self.cte_type=='7bit') |
| 201 | charset = 'utf8' if self.utf8 else 'ascii' |
| 202 | return folded.encode(charset, 'surrogateescape') |
| 203 | |
| 204 | def _fold(self, name, value, refold_binary=False): |
| 205 | if hasattr(value, 'name'): |
no test coverage detected