Solved

convert string to URL validated string?

Posted on 2001-08-18
2
669 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 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