Jump to content



Photo

UnicodeURL UDF


  • Please log in to reply
10 replies to this topic

#1 Dhilip89

Dhilip89

    Insane AutoIt Coder

  • Active Members
  • PipPipPipPipPipPip
  • 360 posts

Posted 01 June 2007 - 01:07 AM

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%20test


AutoIt         
#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

My Projects: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 UDFMy Website:http://dhilip89.hopto.org/Closed Sources:YouTube Video Downloader (Version 1.3)

If 1 + 1 = 10, then 1 + 1 ≠ 2








#2 Pakku

Pakku

    Prodigy

  • Active Members
  • PipPipPip
  • 183 posts

Posted 01 June 2007 - 06:45 AM

This is just where i was looking for, thanks :)

Edited by Pakku, 16 November 2010 - 12:15 AM.

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:http://www.autoitscript.com/fileman/users/arjan%20staring/My profilePM me

#3 Dhilip89

Dhilip89

    Insane AutoIt Coder

  • Active Members
  • PipPipPipPipPipPip
  • 360 posts

Posted 01 June 2007 - 12:59 PM

This is just where i was looking for, thanks :)

Arjan


You're welcome :)
Hope it can help you much.
My Projects: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 UDFMy Website:http://dhilip89.hopto.org/Closed Sources:YouTube Video Downloader (Version 1.3)

If 1 + 1 = 10, then 1 + 1 ≠ 2


#4 Raik

Raik

    Adventurer

  • Active Members
  • PipPip
  • 117 posts

Posted 01 June 2007 - 10:10 PM

_UnicodeURLDecode returns the same string back unchanged (not decoded)
AutoIt-Syntaxsheme for Proton & Phase5Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

#5 Dhilip89

Dhilip89

    Insane AutoIt Coder

  • Active Members
  • PipPipPipPipPipPip
  • 360 posts

Posted 01 June 2007 - 11:53 PM

_UnicodeURLDecode returns the same string back unchanged (not decoded)


Hmm...can you post an example ?
My Projects: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 UDFMy Website:http://dhilip89.hopto.org/Closed Sources:YouTube Video Downloader (Version 1.3)

If 1 + 1 = 10, then 1 + 1 ≠ 2


#6 Raik

Raik

    Adventurer

  • Active Members
  • PipPip
  • 117 posts

Posted 02 June 2007 - 11:06 AM

_UnicodeURLDecode-test.aux
Func _UnicodeURLDecode($toDecode) ... EndFunc consoleWrite(_UnicodeURLDecode('YWRtaW46bXlwYXNz')) ; "YWRtaW46bXlwYXNz" = "admin:mypass"

returns "YWRtaW46bXlwYXNz"

Edited by Raik, 02 June 2007 - 11:10 AM.


#7 Dhilip89

Dhilip89

    Insane AutoIt Coder

  • Active Members
  • PipPipPipPipPipPip
  • 360 posts

Posted 02 June 2007 - 11:53 AM

_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. :)
My Projects: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 UDFMy Website:http://dhilip89.hopto.org/Closed Sources:YouTube Video Downloader (Version 1.3)

If 1 + 1 = 10, then 1 + 1 ≠ 2


#8 Raik

Raik

    Adventurer

  • Active Members
  • PipPip
  • 117 posts

Posted 02 June 2007 - 03:00 PM

sorry, was my mistake.
"YWRtaW46bXlwYXNz" is the base64 encoded HTTP_AUTHORIZATION string.
AutoIt-Syntaxsheme for Proton & Phase5Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

#9 Dhilip89

Dhilip89

    Insane AutoIt Coder

  • Active Members
  • PipPipPipPipPipPip
  • 360 posts

Posted 02 June 2007 - 03:27 PM

sorry, was my mistake.
"YWRtaW46bXlwYXNz" is the base64 encoded HTTP_AUTHORIZATION string.


OK, never mind :)
My Projects: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 UDFMy Website:http://dhilip89.hopto.org/Closed Sources:YouTube Video Downloader (Version 1.3)

If 1 + 1 = 10, then 1 + 1 ≠ 2


#10 4ggr35510n

4ggr35510n

    Wayfarer

  • Active Members
  • Pip
  • 91 posts

Posted 04 November 2010 - 03:33 AM

I love you! You are best!

Thank you for that!

#11 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 04 November 2010 - 04:39 PM

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* Posted Image [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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users