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

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Nov 9, 2016
21
0
Netherlands
#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
 
Nov 9, 2016
21
0
Netherlands
#4
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
 
Nov 9, 2016
21
0
Netherlands
#5
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
 
#6
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