'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 way to know whether the binary
data consists of single byte characters or multibyte characters.
If utf8 is true, headers are encoded to utf8, otherwise to ascii with
non-ASCII unicode rendered as encoded words.'

def fold_binary(self, name, value):

    folded = self._fold(name, value, refold_binary=(self.cte_type == '7bit'))
    charset = ('utf8' if self.utf8 else 'ascii')
    return folded.encode(charset, 'surrogateescape')
