Sign in to follow this  
Followers 0
ValeryVal

AIDNA

1 post in this topic

Since Russian Federation has today received the .РФ top level for IDN,

one can transfer domain names between the encoded (Punycode) notation and the decoded (UTF-8) notation (Russia!) AIDNA.au3:

;===================================================
; AIDNA by Valery Ivanov, 13 March 2010
; It uses service on http://idnaconv.phlymail.de
;===================================================
#include <GUIConstants.au3>
Global $EncodeIn, $DecodeIn

$hWnd = GUICreate("AIDNA © Valery Ivanov, 13 March 2010", 400, 150)
;--------------------------------------------------
$LabelEncode = GUICtrlCreateLabel("Original (Unicode):", 10, 40, 180, 21)
GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
$EncodeIn = GUICtrlCreateInput('правительство.рф', 10, 70, 180, 20)

$LabelDecode = GUICtrlCreateLabel("Punycode (ACE):", 240, 40, 130, 21)
GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
$DecodeIn = GUICtrlCreateInput('xn--80aealotwbjpid2k.xn--p1ai', 200, 70, 180, 20)

$Encode = GUICtrlCreateButton("Encode >>", 100, 100, 90, 21)
$Decode = GUICtrlCreateButton("<< Decode", 200, 100, 100, 21)
GUISetState()

; Start the main loop
While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE
  Exit
Case $Msg = $Decode
  GUICtrlSetData($EncodeIn,"")
  DecodeIt()
Case $Msg = $Encode
  GUICtrlSetData($DecodeIn,"")
  EncodeIt()
EndSelect
WEnd

func DecodeIt()
local $DecodeContent, $EncodeContent
 $DecodeContent = GUICtrlRead($DecodeIn)
 InetGet("http://idnaconv.phlymail.de/index.php?encoded=" & $DecodeContent & "&decode=%3C%3C+Decode", "tmp.html", 1, 0)
 While Not FileExists("tmp.html")
  Sleep(250)
 Wend
 $HTMLSource = FileRead("tmp.html")
 $EncodeContent = _StringBetween($HTMLSource, '<input type="text" name="decoded" value="', '" size="')
 GUICtrlSetData($EncodeIn,$EncodeContent)
 FileDelete("tmp.html")
endfunc

func EncodeIt()
local $DecodeContent, $EncodeContent
 $EncodeContent = BinaryToString(StringToBinary(GUICtrlRead($EncodeIn),4))
 InetGet("http://idnaconv.phlymail.de/index.php?decoded=" & $EncodeContent & "&encode=%3C%3C+Encode", "tmp.html", 1, 0)
 While Not FileExists("tmp.html")
  Sleep(250)
 Wend
 $HTMLSource = FileRead("tmp.html")
 $DecodeContent = _StringBetween($HTMLSource, '<input type="text" name="encoded" value="', '" size="')
 GUICtrlSetData($DecodeIn,$DecodeContent)
 FileDelete("tmp.html")
endfunc

Func _StringBetween($s, $from, $to)
    $x = StringInStr($s, $from) + StringLen($from)
    $y = StringInStr(StringTrimLeft($s, $x), $to)
    Return StringMid($s, $x, $y)
EndFunc

It uses working service on http://idnaconv.phlymail.de


The point of world view

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0