Page 1 of 1

FlexUrlEncoder() for the forum

Posted: Tue Aug 12, 2008 4:56 pm
by Little John
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.

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")
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

Posted: Tue Aug 12, 2008 6:36 pm
by SFSxOI
Little John;

I'm not sure as i've not been able to try it yet, but I think you just solved the one problem I was having when i did the Vista Task Dialogs in this thread: http://www.purebasic.fr/english/viewtop ... taskdialog > where i talk about the url's not working correctly.

Gonna give it a go a little later, maybe your post is the solution. Thank You :)

Posted: Tue Aug 12, 2008 7:23 pm
by Little John
2SFSxOI:
The stuff in the other thread is a bit over my head. However, I'm glad if my little idea gave you another idea. :-) I'm curious now :D, please tell me about your findings.

Regards, Little John