I need up upload urlencoded binary data to tumblr.
this is what I'm currently trying:
开发者_开发技巧 baseString.params = 'data[0]=' + URLEncoding.encode(byte.toString()).replace('~','%257E');
Any Ideas?
Alright, first, it looks like some crazy things are going on with your url encoding. The sample you posted above seems to be double encoded:
>>> x = unescape("%25C3%25BF%25C3%2598%25C3")
>>> x
"%C3%BF%C3%98%C3"
>>> unescape(x)
"ÿÃÃ"
Second, you shouldn't be using ByteArray.toString()
if the ByteArray
contains binary data. Instead, if I recall correctly, you should use ba.readMultiByte(ba.bytesAvailable, "latin1")
which will return a string containing the raw bytes.
Third, I feel like your URLEncoding
class is suspect. Instead, you can just use the escape
(and unescape
) builtins:
>>> escape("\12")
"%0A"
精彩评论