Add URLEncode as a function :D

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

Post Reply
mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Add URLEncode as a function :D

Post by mightycpa » Mon Mar 15, 2021 1:59 am

This one drove me nuts... I was getting HTTP 400 errors, and 10054 Errors. I thought it was the web server.

No. It's the inclusion of a SPACE character within a GET URL instead of %20. I've gone ahead and used the StringReplace> command, but if HTMLEncode could just do it, that would save people having to remember.

Decoding doesn't get convert it back either.
Last edited by mightycpa on Tue Mar 16, 2021 3:15 pm, edited 1 time in total.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1347
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Add SPACE encoding to HTMLEncode/HTMLDecode

Post by Dorian (MJT support) » Mon Mar 15, 2021 12:22 pm

I have passed this on.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Marcus Tettmar
Site Admin
Posts: 7376
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Add SPACE encoding to HTMLEncode/HTMLDecode

Post by Marcus Tettmar » Mon Mar 15, 2021 1:59 pm

Hi,

HTMLEncode/Decode encode and decode HTML, not URLs.

%20 is the URL encoding for a space character. + is also sometimes used.

But in HTML, space is just space. So these functions are working correctly. They are not for encoding/decoding URLs.

Here's a way you can do that:
https://www.mjtnet.com/blog/2018/04/02/ ... -requests/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Add SPACE encoding to HTMLEncode/HTMLDecode

Post by mightycpa » Mon Mar 15, 2021 5:49 pm

I see, HTMLEncode vs. URLEncode.

I've been doing StringReplace>source,SPACE,%20,result and that seems to work.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1347
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Add SPACE encoding to HTMLEncode/HTMLDecode

Post by Dorian (MJT support) » Mon Mar 15, 2021 6:29 pm

That's what I do too.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Grovkillen
Automation Wizard
Posts: 998
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Add URLEncode as a function :D

Post by Grovkillen » Mon Apr 12, 2021 12:23 pm

Note to self and others....

Just use the "UnEscape" to replace ALL those URL escaped characters.

Code: Select all

Let>JSON_STRING=%22change%22:%22produktion-article-info-hyllplats%3E%3E%3EK1%3C%3C%3C%22,%22value%22:%22K112%22,%22job%22:%2247433-2%22,%22article%22:%22212-160-12000%22
VBEval>UnEscape("%JSON_STRING%"),JSON_STRING
//JSON_STRING="change":"produktion-article-info-hyllplats>>>K1<<<","value":"K112","job":"47433-2","article":"212-160-12000"
And the other way around is this:

Code: Select all

Let>JSON_STRING="change":"produktion-article-info-hyllplats>>>K1<<<","value":"K112","job":"47433-2","article":"212-160-12000"
VBEval>Escape("%JSON_STRING%"),JSON_STRING
//JSON_STRING=%22change%22:%22produktion-article-info-hyllplats%3E%3E%3EK1%3C%3C%3C%22,%22value%22:%22K112%22,%22job%22:%2247433-2%22,%22article%22:%22212-160-12000%22
Let>ME=%Script%

Running: 15.0.24
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts