in Eski Blog Yazılarım

Server.URLEncode & URLDecode

Bloğu onarırken titlelara takıldım daha işlevsel bir title için kolları sıvadım önce Server.URLEncode ile encode ettim linklerde sonra titleda göstermem gerektiğinde de aşağıdaki fonksiyonu kullandım. URLDecode. VBScript.RegExp kullanması ayrı bir karizma katıyor koda. Şık yani. ;)

function URLDecode(sText)
sDecoded = sText
Set oRegExpr = Server.CreateObject("VBScript.RegExp")
oRegExpr.Pattern = "%[0-9,A-F]{2}"
oRegExpr.Global = True
Set oMatchCollection = oRegExpr.Execute(sText)
For Each oMatch In oMatchCollection
sDecoded = Replace(sDecoded,oMatch.value,Chr(CInt("&H" & Right(oMatch.Value,2))))
Next
sDecoded = Replace(sDecoded ,"+"," ")
URLDecode = sDecoded
End function

Kaynak 1 : http://www.thescripts.com/forum/post192945-3.html
Kaynak 2 : http://www.motobit.com/tips/detpg_URLDecode/

Yorum Bırak

Comment