开发者

How to urlencode an Actionscript ByteArray

开发者 https://www.devze.com 2023-04-04 19:30 出处:网络
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\');

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"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号