Results 1 to 5 of 5

Thread: Encoding URL for inet control

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Argentina
    Posts
    11

    Exclamation

    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
    vbphantom

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Constructing the URL string is a two-stage process.

    Stage 1: Replace codes
    Code:
    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:
    Code:
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Argentina
    Posts
    11
    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)
    vbphantom

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Argentina
    Posts
    11

    Thumbs up

    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.
    vbphantom

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width