def encode_header_param(param_text):
 if (not param_text):
  return ''
 param_text_utf8 = ustr(param_text).encode('utf-8')
 param_text_ascii = try_coerce_ascii(param_text_utf8)
 return (param_text_ascii or Charset('utf8').header_encode(param_text_utf8))

def encode_header_param ( param_text ) : if ( not param_text ) : return '' param_text_utf8 = ustr ( param_text ) . encode ( 'utf-8' ) param_text_ascii = try_coerce_ascii ( param_text_utf8 ) return ( param_text_ascii or Charset ( 'utf8' ) . header_encode ( param_text_utf8 ) )
returns an appropriate rfc2047 encoded representation of the given header parameter value .