Solved

convert string to URL validated string?

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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