SV650.org - SV650 & Gladius 650 Forum



Idle Banter For non SV and non bike related chat (and the odd bit of humour - but if any post isn't suitable it'll get deleted real quick).
There's also a "U" rating so please respect this. Newbies can also say "hello" here too.

Reply
 
Thread Tools
Old 13-07-07, 02:51 PM   #1
timwilky
Member
Mega Poster
 
timwilky's Avatar
 
Join Date: Mar 2004
Location: Not in Yorkshire. (Thank God)
Posts: 4,116
Default windows script help needed

I need to encode some text in order to use it within a url.

for instance space characters need to be encoded as %20 etc.

I was tying to use the character substitution in an environment variable

for instance

SET STRING=%1%
SET STRING=%STRING: =%20% (How to I escape the % in the %20)
echo %STRING%

Where the argument to the script would be the text to encode " delimited, ie. "encode this string" where I would expect the output to be "encode%20this%20string"

Otherwise I am going to have to write a bit of C just to do this noddy requirement.
__________________
Not Grumpy, opinionated.

Last edited by timwilky; 13-07-07 at 02:54 PM.
timwilky is offline   Reply With Quote
Old 13-07-07, 02:54 PM   #2
plowsie
Guest
 
Posts: n/a
Default Re: windows script help needed

Encode was where i got confused Tim sorry mate lol
  Reply With Quote
Old 13-07-07, 03:22 PM   #3
johnnyrod
Member
Mega Poster
 
johnnyrod's Avatar
 
Join Date: Jul 2003
Location: Doncaster, oop norf
Posts: 2,128
Default Re: windows script help needed

Does this help? Can you adapt it? Try PMing TSM, he's a geek.

http://www.syronex.com/antispam/help...cipient-mailto
johnnyrod is offline   Reply With Quote
Old 13-07-07, 03:25 PM   #4
timwilky
Member
Mega Poster
 
timwilky's Avatar
 
Join Date: Mar 2004
Location: Not in Yorkshire. (Thank God)
Posts: 4,116
Default Re: windows script help needed

unfortunately that is javascript. What I am attempting to do is format arguments that I will pass to a wget command. So they have to look as if a browser etc has already encoded them
__________________
Not Grumpy, opinionated.
timwilky is offline   Reply With Quote
Old 13-07-07, 03:29 PM   #5
rigor
Guest
 
Posts: n/a
Default Re: windows script help needed

I'm guessing it's not just spaces your trying to encode as %20

If it is, does this little batch file help?

@echo off
echo %1%%20%2%%20%3

run it as test.bat test1 test2 test3
and the output is
test1%20test2%20test3

Probably a bit basic, and not sure how you would make it work for different length strings though ....
  Reply With Quote
Old 13-07-07, 05:05 PM   #6
TSM
The Sick Man
Mega Poster
 
TSM's Avatar
 
Join Date: Nov 2004
Location: Peckham.SE.LDN
Posts: 4,768
Default Re: windows script help needed

i assume that you are using the linux "wget" port, you could with a perl script do below.

Code:
#!/usr/bin/perl

sub URLenc{
$urlstr = $_[0];
$urlstr =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
return $urlstr;
}

print URLenc(shift);
just realised that if you are using wget then if you put the url in """" etc then it automaticly does the convert for you,
Code:
wget "http://server/file to get.html"
__________________
OTR: KTM 690 Duke R 2015 Full Akro
SIDELINE: Kwak ZX636 A1P 2002, Red, R&G's, Yoshi, Double Bubble Screen
GONE: Kwak ZX-7R P1, Full Akro, Undertray, Screen
GONE: SV650S K2 Very Bruised & Without Fairing, Motovation Frame Sliders, R&G Ally Sprocket Toe Protector, HEL 2 Line Setup, GSXR K1 600 RWU Forks, Barnett Clutch & Springs, Penske 8981 Shock, Gilles Ti Rearsets, Steel Barends, Scottoiler, AFAM Chain & Sprockets, Twin FIAMM Horns, Skidmarx Bellypan, Full Micron Zeta Steel System, Cut down undertay.

Forum Problems & Information / Site Suggestions
TSM is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rainbow script that never was Defender Idle Banter 2 18-04-08 02:59 PM
Windows Media Player... Help Needed! Speedy Claire Idle Banter 17 02-02-08 01:12 PM
Windows script help tricky Idle Banter 2 29-03-07 11:55 AM
Windows 97 Help needed re format painter mattSV Idle Banter 4 25-10-06 04:11 PM
Script help sharriso74 Idle Banter 13 03-02-06 03:53 PM


All times are GMT. The time now is 02:36 PM.


Powered by vBulletin® - Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.