Click to See Complete Forum and Search --> : Encoding URL for inet control
vbphantom
Aug 28th, 2000, 01:15 PM
hi!
I´m needing some help with the inet control.
I just need to get some pages from a web server with the OpenURL method. This method takes an URL (a String) as parameter.
The point is, i need to encode the URL to 'aplication/x-www-form-encoded' (you know, this replaces some characters by codes), but i could not find anything that do that in VB.
I´ve tried MSDN, this and other forums, and more, but nothing seems to work.
Remarks: I´m working with pure VB (not ASP)
Please, I need help (my job is depending of this).
Thanks
parksie
Aug 28th, 2000, 01:35 PM
Constructing the URL string is a two-stage process.
Stage 1: Replace codes
Dim sMyValue as String
sMyValue = "Here is a string with ~codes &in"
' Loop through all values that would need replacing
sMyValue = Replace("~", "%7e")
sMyValue = Replace("&", "%26")
Stage 2: Concatenate into URL string:
Dim sURL as String
sURL = "http://www.myplace.com/cgi-bin/f.pl?"
sURL = sURL & sMyValueName & "=" & sMyValue
Where sMyValueName=sMyValue, sMyValue having been configured in stage 1.
vbphantom
Aug 28th, 2000, 03:33 PM
Thanks, that´s a good idea, but I forget to say that the URL is an argument entered by the user, then i need to prevent any character in the URL.
In this case I´ll need the entire table character-code of the 'aplication/x-www-form-encoded' code.
If anybody can give me a way to find this codes, I´ll have the complete solution. (I was trying to find it int the net with no results)
parksie
Aug 29th, 2000, 12:14 PM
The character codes are merely "%" followed by a two-character hex string for it's ASCII code:
"~" = ASCII code 126 = &H7E = "%7E"
At a crunch, you can encode every character (ouch), or I'll try and find a replace table.
vbphantom
Aug 29th, 2000, 04:26 PM
thanks,
I´ve find the generation rule for the codes, it is:
The ASCII characters 'a' through 'z', 'A' through 'Z', '0' through '9', and ".", "-", "*", "_" remain the same.
The space character ' ' is converted into a plus sign '+'.
All other characters are converted into the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the lower 8-bits of the character.
I´ve made a little function that converts the URL string and it's working fine (and i´m remain working too!)
Thanks again.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.