'Header-encode a string by converting it first to bytes.
The type of encoding (base64 or quoted-printable) will be based on
this charset\'s `header_encoding`.
:param string: A unicode string for the header.  It must be possible
to encode this string to bytes using the character set\'s
output codec.
:return: The encoded string, with RFC 2047 chrome.'

def header_encode(self, string):

    codec = (self.output_codec or 'us-ascii')
    header_bytes = _encode(string, codec)
    encoder_module = self._get_encoder(header_bytes)
    if (encoder_module is None):
        return string
    return encoder_module.header_encode(header_bytes, codec)
