Solved

convert string to URL validated string?

Posted on 2001-08-18
2
657 Views
Last Modified: 2010-04-04


Has someone function/procedure for converting strings to URL validated text?

for example to convert

http://www.somesite.com is "the best"

to

http%3A%2F%2Fwww.somesite.com+is+%22the+best%22

thanks in advance.
0
Comment
Question by:kzdown
2 Comments
 
LVL 2

Accepted Solution

by:
bugroger earned 45 total points
ID: 6403187
Hi,

do you mean something like that?:

Function StringToUrl(S : String) : String;
VAR
 z : Integer;
Begin
 Result := '';
 For z := 1 to Length(s) do
 Begin
  Case s[z] Of
   ' '  : Result := Result + '+';
   ':'  : Result := Result + '%' + IntToHex(Ord(':'), 2);
   '/'  : Result := Result + '%' + IntToHex(Ord('/'), 2);
   '"'  : Result := Result + '%' + IntToHex(Ord('"'), 2);
   else   Result := Result + s[z];
  End;
 End;
End;

Function URLToString(Url : String) : String;
VAR
 z      : Integer;
 hexStr : String;
Begin
 Result := '';
 z := 1;
 While z <= Length(Url) do
 Begin
  Case URL[z] Of
   '+'  : Result := Result + ' ';
   '%'  : Begin
           Result := Result + Chr(StrToInt('$' + URL[z +1] + URL[z +2]));
           Inc(z, 2);
          End;
   else   Result := Result + URL[z];
  End;
  Inc(z);
 End;
End;

GL
 Bug
0
 

Author Comment

by:kzdown
ID: 6404619
yes. exactly what i needed.
thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question