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.

help replacing some extended ascii characters

Old posts that have not been replied to for several years.
b
blotter45
Voice
Posts: 17
Joined: Mon Feb 28, 2005 8:37 am

Post by blotter45 »

Ofloo wrote:% time "urlEncode $url" 100
203 microseconds per iteration

% time "slowUrlEncode $url" 100
379 microseconds per iteration
%

here a simple proc that is bit faster then the one above ..

Code: Select all

proc urlEncode {url} {
  if {[regexp {(.*)\?(.*)} $url -> pre sur]} {
    set result ${pre}?
    foreach {x} [split $sur {}] {
      if {[regexp {[^a-zA-Z0-9=%]} $x]} {
        append result "%[format %02x [scan $x %c]]"
      } else {
      	append result $x
      }
    }
    return $result
  }
  return $url
}
this proc doesn't seem to work with extended ascii chars, but the slowurlencode proc posted by user does work, anyway thanks alot to you all for your help with this!! ;)
b
blotter45
Voice
Posts: 17
Joined: Mon Feb 28, 2005 8:37 am

Post by blotter45 »

Ofloo wrote:

Code: Select all

proc urlEncode {url} {
  if {[regexp {(.*)\?(.*)} $url -> pre sur]} {
    set result ${pre}?
    foreach {x} [split $sur {}] {
      if {[regexp {[^a-zA-Z0-9=%]} $x]} {
        append result "%[format %02x [scan $x %c]]"
      } else {
      	append result $x
      }
    }
    return $result
  }
  return $url
}
sorry edited it for got a %
Just tried out your revision ofloo, but it still doesn't work with extended ascii characters (it just sends out the characters unchanged) ;)

But atleast the slowurlencode proc does work, so I'm happy enough with that ;)
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

not sur what you mean but to me it seems to work
just curious probably wrong tho ;) not sur if i should remove the % from the exempt list
XplaiN but think of me as stupid
Locked