Dhilip89 Posted June 1, 2007 Posted June 1, 2007 Hello, this is my first release of UDF for AutoIt.This UDF is designed for work with Unicode string, so only use it with AutoIt3.exe (Unicode Version).I have used it on my project for unicode URL Encoding and Decoding.This is an example project that used this UDF:http://dhilip89.hopto.org/autoit%20test/li.../unicode%20testexpandcollapse popup#include-once ;=============================================================================== ; _UnicodeURLEncode() ; Description: : Encodes an unicode string to be URL-friendly ; Parameter(s): : $UnicodeURL - The Unicode String to Encode ; Return Value(s): : The URL encoded string ; Author(s): : Dhilip89 ; Note(s): : - ; ;=============================================================================== Func _UnicodeURLEncode($UnicodeURL) $UnicodeBinary = StringToBinary ($UnicodeURL, 4) $UnicodeBinary2 = StringReplace($UnicodeBinary, '0x', '', 1) $UnicodeBinaryLength = StringLen($UnicodeBinary2) Local $EncodedString For $i = 1 To $UnicodeBinaryLength Step 2 $UnicodeBinaryChar = StringMid($UnicodeBinary2, $i, 2) If StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", BinaryToString ('0x' & $UnicodeBinaryChar, 4)) Then $EncodedString &= BinaryToString ('0x' & $UnicodeBinaryChar) Else $EncodedString &= '%' & $UnicodeBinaryChar EndIf Next Return $EncodedString EndFunc ;==>_UnicodeURLEncode ;=============================================================================== ; _UnicodeURLDecode() ; Description: : Tranlates a URL-friendly string to a normal string ; Parameter(s): : $toDecode - The URL-friendly string to decode ; Return Value(s): : The URL decoded string ; Author(s): : nfwu, Dhilip89 ; Note(s): : Modified from _URLDecode() that's only support non-unicode. ; ;=============================================================================== Func _UnicodeURLDecode($toDecode) Local $strChar = "", $iOne, $iTwo Local $aryHex = StringSplit($toDecode, "") For $i = 1 To $aryHex[0] If $aryHex[$i] = "%" Then $i = $i + 1 $iOne = $aryHex[$i] $i = $i + 1 $iTwo = $aryHex[$i] $strChar = $strChar & Chr(Dec($iOne & $iTwo)) Else $strChar = $strChar & $aryHex[$i] EndIf Next $Process = StringToBinary (StringReplace($strChar, "+", " ")) $DecodedString = BinaryToString ($Process, 4) Return $DecodedString EndFunc ;==>_UnicodeURLDecode #endregion mLipok 1 [u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]
Pakku Posted June 1, 2007 Posted June 1, 2007 (edited) This is just where i was looking for, thanks Edited November 16, 2010 by Pakku How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:My filemanMy profilePM me
Dhilip89 Posted June 1, 2007 Author Posted June 1, 2007 This is just where i was looking for, thanks ArjanYou're welcome Hope it can help you much. [u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]
Raik Posted June 1, 2007 Posted June 1, 2007 _UnicodeURLDecode returns the same string back unchanged (not decoded) AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)
Dhilip89 Posted June 1, 2007 Author Posted June 1, 2007 _UnicodeURLDecode returns the same string back unchanged (not decoded)Hmm...can you post an example ? [u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]
Raik Posted June 2, 2007 Posted June 2, 2007 (edited) _UnicodeURLDecode-test.aux Func _UnicodeURLDecode($toDecode) ... EndFunc consoleWrite(_UnicodeURLDecode('YWRtaW46bXlwYXNz')) ; "YWRtaW46bXlwYXNz" = "admin:mypass" returns "YWRtaW46bXlwYXNz" Edited June 2, 2007 by Raik AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)
Dhilip89 Posted June 2, 2007 Author Posted June 2, 2007 _UnicodeURLDecode-test.aux Func _UnicodeURLDecode($toDecode) ... EndFunc consoleWrite(_UnicodeURLDecode('YWRtaW46bXlwYXNz')) ; "YWRtaW46bXlwYXNz" = "admin:mypass" returns "YWRtaW46bXlwYXNz" Hmm...Seems you misunderstood what this function use for. This function is designed for URL Encoding and Decoding, this is an example of how it is used for, The unicode string : Ελληνικά You can't use these type character to request something from webservers, so you need to encode it: $UnicodeStr = "Ελληνικά" When we use _UnicodeURLEncode($UnicodeStr), it will return : %CE%95%CE%BB%CE%BB%CE%B7%CE%BD%CE%B9%CE%BA%CE%AC When we want to change the URL encoded strings to the text we understand, just use this: $URLStr = "%CE%95%CE%BB%CE%BB%CE%B7%CE%BD%CE%B9%CE%BA%CE%AC" _UnicodeURLDecode($URLStr) It will turn the encoded URL back to normal: Ελληνικά Hope this information can help you. [u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]
Raik Posted June 2, 2007 Posted June 2, 2007 sorry, was my mistake. "YWRtaW46bXlwYXNz" is the base64 encoded HTTP_AUTHORIZATION string. AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)
Dhilip89 Posted June 2, 2007 Author Posted June 2, 2007 sorry, was my mistake."YWRtaW46bXlwYXNz" is the base64 encoded HTTP_AUTHORIZATION string.OK, never mind [u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]
4ggr35510n Posted November 4, 2010 Posted November 4, 2010 I love you! You are best! Thank you for that!
ProgAndy Posted November 4, 2010 Posted November 4, 2010 I love you! You are best!Thank you for that!I have written functions for URL-encoding in UTF8, too: http://www.autoitscript.com/forum/index.php?showtopic=95850&view=findpost&p=689060 *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
GeorgeR Posted August 18, 2015 Posted August 18, 2015 Thank you very much for this. Saved a lot of time!
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