Solved

convert string to URL validated string?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

24 Experts available now in Live!

Get 1:1 Help Now