Solved

convert string to URL validated string?

Posted on 2001-08-18
2
636 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now