Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Use TPIPE to replace " " with "%20" in URLs ?

Nov
76
1
Hi all.

I've been tinkering with TPIPE to substitute spaces with "%20" in a text file containing an URL list.
But it doesn't work.

Either the space is removed and not substituted or my request is simply ignored.

Syntax I use is this:

TPIPE /REPLACE=0,0,0,0,0,0,0,0,0,"input-string","output-string" /INPUT=file1 /OUTPUT=file2

So you would think it would be easy to do this, but the %20 is confusing TCC.

I tried "%20", "%%20", `%20`, `%%20` and the same quoted, and also as %@CHAR[37]20...
I also used the escape character before the % (in my case ^X / ASCII 24) but it just doesn't work.

Anyone know why?

Thanks.
x13
 
It sounds like you should have it! This works.
Code:
v:\> type p20.txt
%20
%20

v:\> tpipe /input=p20.txt /replace=0,0,0,0,0,0,0,0,0,"%%20",foo
foo
foo
 
Here's another.
Code:
v:\> type p20.txt
abc %20 def
ghi %20 jkl

v:\> tpipe /input=p20.txt /replace=0,0,0,0,0,0,0,0,0,"%%20","   "
abc     def
ghi     jkl
 
Hi Vince.

I'm trying to replace spaces with "%20" not the other way around (if it makes any difference).

I create file url.txt with the following content :

site.com/containing some spaces.htm
anothersite.com/with a few more spaces.htm

TPIPE /REPLACE=0,0,0,0,0,0,0,0," ","%20" /INPUT=url.txt
yields :

site.com/containingsomespaces.htm
anothersite.com/withafewmorespaces.htm

SETDOS
ANSI=1
COMPOUND=^ (ascii 94)
DESCRIPTIONS=1 (DESCRIPT.ION)
ESCAPE=↑ (ascii 24)
EVAL=0.10
EXPANSION=0
MODE=1
NOCLOBBER=0
PARAMETERS=$ (ascii 36)
CURSOR OVERSTRIKE=100
CURSOR INSERT=15
VERBOSE=1

and UnicodeOutput=Off in TCMD.INI

It's not a huge drama, but I don't get why this is not working -- especially is I put %20 between `` (reverse quotes).

I thought of using %@URLENCODE[], but this messes up the URL and replaces spaces with "+"; soI would still have the same problem replacing those with "%20".

Any other ideas?...

x13

Example
 
Hmm... Now I'm perplexed..

I know I use the right syntax.

And Vince, I noticed you used "%%20", which I hadn't noticed.
I could swear I tried that also in my testing...

One other problem I experienced (which I had not yet mentioned) is that a TPIPE might work on the command line, but no longer in a BTM file.

Now, strangely enough, using "%%20" seems to hit the bullseye. On both accounts.

So problem solved.
Thanks.

x13
 
Your /replace spec should have 9 zeroes. These work.
Code:
g:\tc21> echo foo bar | tpipe /replace=0,0,0,0,0,0,0,0,0," ","%%20"
foo%20bar

g:\tc21> echo foo bar > foobar.txt

g:\tc21> tpipe /input=foobar.txt /replace=0,0,0,0,0,0,0,0,0," ","%%20"
foo%20bar
 
Back
Top