#NEWLINE# def urlencode( query , doseq = 0 ) : #NEWLINE# #INDENT# "\n    A version of Python's urllib.urlencode() function that can operate on\n    unicode strings. The parameters are first case to UTF-8 encoded strings and\n    then encoded as per normal.\n    " #NEWLINE# if hasattr ( query , 'items' ) : #NEWLINE# #INDENT# query = query . items ( ) #NEWLINE# #UNINDENT# return urllib . urlencode ( [ ( smart_str ( k ) , ( ( isinstance ( v , ( list , tuple ) ) and [ smart_str ( i ) for i in v ] ) or smart_str ( v ) ) ) for ( k , v ) in query ] , doseq )