I have a list that I need to send through a URL to a third party vendor. I don’t know what language they are using.
The list prints out like this:
[u'1', u'6', u'5']
I know that the u encodes the string in utf-8 right? So a couple of questions.
Can I send a list through a URL?
Will the u’s show up on the other end when going through the URL?
If so, how do I remove them?
I am not sure what keywords to search to help me out, so any resources would be helpful too.
No. A URL is just text. If you want a way to package structured information in it, you’ll have to agree that with the provider you’re talking to.
One standard encoding for structure in URLs, that might or might not be what you need, is the use of multiple parameters with the same name in a query string. This format comes from HTML form submissions:
might be considered to represent a parameter
parwith a three-item list as its value. Or maybe not, it’s up to the receiver to decide. For example in a PHP application you would have had to name the parameterpar[]to get it to accept the array value.No. a
u'...'string is a native Unicode string, where each index represents a whole character and not a byte in any particular encoding. If you want UTF-8 bytes, writeu'...'.encode('utf-8')before URL-encoding. UTF-8 is a good default choice, but again: what encoding the receiving side wants is up to that application.uis part of the literal representation of the string, just the same as the'quotes themselves. They are not part of the string value and would not be echoed byprintor when joined into other strings, unless you deliberately asked for the literal representation by callingrepr.