code: def header_encode(header_bytes, charset='iso-8859-1'):
      
      # Return empty headers as an empty string.
      if not header_bytes:
          return ''
      # Iterate over every byte, encoding if necessary.
      encoded = []
      for octet in header_bytes:
          encoded.append(_QUOPRI_HEADER_MAP[octet])
      # Now add the RFC chrome to each encoded chunk and glue the chunks
      # together.
      return '=?%s?q?%s?=' % (charset, EMPTYSTRING.join(encoded))
docs: Encode a single header line with quoted-printable (like) encoding.
  
      Defined in RFC 2045, this `Q' encoding is similar to quoted-printable, but
      used specifically for email header fields to allow charsets with mostly 7
      bit characters (and some 8 bit) to remain more or less readable in non-RFC
      2045 aware mail clients.
  
      charset names the character set to use in the RFC 2046 header.  It
      defaults to iso-8859-1.