def encode_header(header_text):
 if (not header_text):
  return ''
 header_text_utf8 = ustr(header_text).encode('utf-8')
 header_text_ascii = try_coerce_ascii(header_text_utf8)
 return (header_text_ascii or Header(header_text_utf8, 'utf-8'))

def encode_header ( header_text ) : if ( not header_text ) : return '' header_text_utf8 = ustr ( header_text ) . encode ( 'utf-8' ) header_text_ascii = try_coerce_ascii ( header_text_utf8 ) return ( header_text_ascii or Header ( header_text_utf8 , 'utf-8' ) )
returns an appropriate representation of the given header value .