squadjot Posted July 9, 2012 Share Posted July 9, 2012 (edited) Hi, i'm looking for some functionality that can unescape strings that has been encoded. First and foremost i'm looking for a plain alternative to javascripts unescape() Func _URIDecode($sData) ; Prog@ndy Local $aData = StringSplit(StringReplace($sData,"+"," ",0,1),"%") $sData = "" For $i = 2 To $aData[0] $aData[1] &= Chr(Dec(StringLeft($aData[$i],2))) & StringTrimLeft($aData[$i],2) Next Return BinaryToString(StringToBinary($aData[1],1),4) EndFunc It only works if all characters are escaped..it can not be mixed. for an example, it fails if the string contains a unescaped %.. $myres1 = _URIDecode('Jo%C3%A3o%20Guimar%C3%A3es%20Rosa') ConsoleWrite($myres1 & @CRLF) ; Outputs: "João Guimarães Rosa" - (Works fine!) $myres2 = _URIDecode("I was about 99% done!") ConsoleWrite($myres2 & @CRLF) ; Outputs: "I was about 99" So..before is start improving the above snippet, do a library exist that can handle these things? (HTML en/decoding would be nice) EDIT: Hmm..i just tried javascripts method.. it also fails when single %... offcourse.. hmm.. nevermind. My question is answered.. ill leave the post Edited July 9, 2012 by squadjot Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted July 9, 2012 Share Posted July 9, 2012 Is the following what your looking for? Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
squadjot Posted July 9, 2012 Author Share Posted July 9, 2012 Yes, that seems better, thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now