This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

parsing url strings

Old posts that have not been replied to for several years.
Locked
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

parsing url strings

Post by Ofloo »

as you know all weird chars will be formated to hex using % as a hex symbol, i am trying to parse data from for example %3A to \x3A and resolve it without saving it into \x3A

Code: Select all

foreach {x} [split [lindex [split $url \x3F] 1] \x26] {   
  if {[regexp {^(.+?)\x3D(.*)$} $x str name value]} {
    set _GET([join [string map {\x2B \x20 \x25 \\x} $name]]) [join [string map {\x2B \x20 \x25 \\x} $value]]
  }
}
now i need to join in order to resolve it.. also in some cases it gives a weird result for example when using '=' and right after it a 'd' don't know why '=d'
out puts a weird result (greek beta letter) .. instead of =d
XplaiN but think of me as stupid
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

"resolve it"? what do you mean? and what are you actually trying to accomplish?

you might wish to check Tcllib's package uri
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

nvm and its not in uri as far as i can say for those who want it ..

Code: Select all

proc mapHex {pre} {
  set i 0
  while {$i < 1} {
    if {[regexp {(.*)%([0-9a-zA-Z]{2})(.*)} $pre str pre hex end]} {
      if {[info exists r]} {
        set r [format %c 0x${hex}]$end$r
      } else {
        set r [format %c 0x${hex}]$end	
      }
    } else {
      if {[info exists r]} {
        return "${pre}${r}"
      } else {
      	return $pre
      }
    }
  }
}
XplaiN but think of me as stupid
Locked