def encode_rfc2231(s, charset=None, language=None):
 import urllib
 s = urllib.quote(s, safe='')
 if ((charset is None) and (language is None)):
  return s
 if (language is None):
  language = ''
 return ("%s'%s'%s" % (charset, language, s))

def encode_rfc2231 ( s , charset = None , language = None ) : import urllib s = urllib . quote ( s , safe = '' ) if ( ( charset is None ) and ( language is None ) ) : return s if ( language is None ) : language = '' return ( "%s'%s'%s" % ( charset , language , s ) )
encode string according to rfc 2231 .