Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to encode a HTTP URL Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
21-Jan-03
Category
Internet / Web
Language
Delphi 2.x
Views
157
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Lou Adler

How to encode a HTTP URL?

Answer:

1   function HTTPEncode(const AStr: string): string;
2   const
3     NoConversion = ['A'..'Z', 'a'..'z', '*', '@', '.', '_', '-'];
4   var
5     Sp, Rp: PChar;
6   begin
7     SetLength(Result, Length(AStr) * 3);
8     Sp := PChar(AStr);
9     Rp := PChar(Result);
10    while Sp^ <> #0 do
11    begin
12      if Sp^ in NoConversion then
13        Rp^ := Sp^
14      else if Sp^ = ' ' then
15        Rp^ := '+'
16      else
17      begin
18        FormatBuf(Rp^, 3, '%%%.2x', 6, [Ord(Sp^)]);
19        Inc(Rp, 2);
20      end;
21      Inc(Rp);
22      Inc(Sp);
23    end;
24    SetLength(Result, Rp - PChar(Result));
25  end;
26  
27  procedure TForm1.Button1Click(Sender: TObject);
28  begin
29    Edit1.Text := HTTPEncode(Edit1.Text);
30  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC