frank10 Posted March 6, 2020 Posted March 6, 2020 (edited) URLdecode does not work well: #include <WinHttp.au3> #include <WinHttpConstants.au3> local $text = "rápido" MsgBox(0,'', URLDecode(__WinHttpURLEncode($text)) ) ; __WinHttpURLEncode translates "á" correctly with %C3%A1, but URLdecode (I found it in the forum) does not reverse it right. Func URLDecode($urlText) $urlText = StringReplace($urlText, "+", " ") Local $matches = StringRegExp($urlText, "\%([abcdefABCDEF0-9]{2})", 3) If Not @error Then For $match In $matches $urlText = StringReplace($urlText, "%" & $match, BinaryToString('0x' & $match)) Next EndIf Return $urlText EndFunc ;==>URLDecode Any idea how to solve? Edited March 6, 2020 by frank10
Nine Posted March 6, 2020 Posted March 6, 2020 Try this (partly tested) : #include <Constants.au3> #include <WinHttp.au3> #include <WinHttpConstants.au3> Local $text = "rápidéo èthïmê" Local $sEncode = __WinHttpURLEncode($text) MsgBox(0, '', $sEncode) MsgBox (0,"",URLDecode($sEncode)) Func URLDecode($urlText) Local $sDecoded $urlText = StringReplace($urlText, "+", " ") Local $matches = StringRegExp($urlText, "\%([a-fA-F0-9]{2})", 3) If Not @error Then For $i = 0 To UBound($matches) - 1 $matches[$i] = Dec($matches[$i]) Next $sDecoded = StringFromASCIIArray($matches, 0, -1, 2) $urlText = StringRegExpReplace($urlText, "\%([a-fA-F0-9]{2})\%([a-fA-F0-9]{2})", "%%") For $i = 1 To StringLen($sDecoded) $urlText = StringReplace($urlText, "%%", StringMid($sDecoded, $i, 1), 1, 1) Next EndIf Return $urlText EndFunc ;==>URLDecode “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Nine Posted March 6, 2020 Posted March 6, 2020 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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