Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 66,982 of 68,980    |
|    JJ to Tom Del Rosso    |
|    Re: Poison characters in substring subst    |
|    17 Jul 17 19:59:37    |
   
   From: jj4public@vfemail.net   
      
   On Sun, 16 Jul 2017 12:50:07 -0400, Tom Del Rosso wrote:   
   > Trying to change "%20" in a url into a space.   
   >   
   > Tried various forms including these, and none work.   
   >   
   > set "url=%url:%20= %"   
   >   
   > ....or...   
   >   
   > call set "url=%url:%%20= %"   
   >   
   > ....or other forms.   
   >   
   > I though delayed expansion would work as a last resort, but that fails   
   > too.   
      
   Work around it. e.g.   
      
   @echo off   
   setlocal   
   set url=abc%%20def%%3D123%%3A456   
   echo Before: %url%   
   call :decodeUrl   
   echo After : %url%   
   goto :eof   
      
   :replacePercentChars   
   set prev=%url%   
   for /f "tokens=1,* delims=%%" %%A in ("%url%") do (   
    if not "%%B" == "" set url=%%A.%%B   
   )   
   if "%url%" == "%prev%" goto :eof   
   goto replacePercentChars   
      
   :replaceSpaceEntities   
   set prev=%url%   
   set url=%url:.20= %   
   if "%url%" == "%prev%" goto :eof   
   goto replaceSpaceEntities   
      
   :replaceEqualEntities   
   set prev=%url%   
   set url=%url:.3D==%   
   if "%url%" == "%prev%" goto :eof   
   goto replaceEqualEntities   
      
   :replaceColonEntities   
   set prev=%url%   
   set url=%url:.3A=:%   
   if "%url%" == "%prev%" goto :eof   
   goto replaceColonEntities   
      
   :decodeUrl   
   call :replacePercentChars   
   call :replaceSpaceEntities   
   call :replaceEqualEntities   
   call :replaceColonEntities   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca