FlexUrlEncoder() for the forum
Posted: Tue Aug 12, 2008 4:56 pm
Works also with PB 5.20
Hi all,
the forum software does not acceopt certain characters in links, which normally can be contained in URLs, e.g. http://msdn.microsoft.com/en-us/library ... S.85).aspx is not "clickable" because of the brackets.
Since brackets normally can be contained in an URL, they will not be encoded by PB's built-in URLEncoder() function. That's why I wrote the following little encoding function, which makes it easier for us to provide "clickable" links here in the forum.
Are there characters other than "(" and ")", which are normally allowed in URLs but are not accepted as part of links here in the forum?
Regards, Little John
Hi all,
the forum software does not acceopt certain characters in links, which normally can be contained in URLs, e.g. http://msdn.microsoft.com/en-us/library ... S.85).aspx is not "clickable" because of the brackets.
Since brackets normally can be contained in an URL, they will not be encoded by PB's built-in URLEncoder() function. That's why I wrote the following little encoding function, which makes it easier for us to provide "clickable" links here in the forum.
Code: Select all
EnableExplicit
Procedure.s FlexUrlEncoder (url.s, charlist.s="()")
; charlist: List of *additionally* to encode characters
Protected i.i, char.s
url = URLEncoder(url) ; Most work will be done by the built-in function.
For i = 1 To Len(charList)
char = Mid(charlist, i, 1)
url = ReplaceString(url, char, "%" + Hex(Asc(char)))
Next
ProcedureReturn url
EndProcedure
;-- Demo
Debug URLEncoder("http://msdn.microsoft.com/en-us/library/ms644906(VS.85).aspx")
Debug FlexUrlEnCoder("http://msdn.microsoft.com/en-us/library/ms644906(VS.85).aspx")
Regards, Little John