1. Miguel Leeuwe
  2. PowerBuilder
  3. Friday, 12 February 2021 03:52 AM UTC

Hi,

I've used an Inet variable to be able to use the HyperlinkToURL() function.
I thought it would be a good idea to use the CoderObject to UrlEncode() the url that I'm passing in.

My URL's can point to anything like "file://..." or "http(s)//...".
The problem I'm having is that the function encodes every character !

If I would use Appeon's example to create a url for HyperLinkToUrl(), it wouldn't work, since the colon and slashes and dots all  would be changed to "%whatever".

Blob lblb_data
String ls_UrlStr

lblb_data = Blob("https://www.appeon.com", EncodingANSI!)

CoderObject lnv_CoderObject
lnv_CoderObject = Create CoderObject
ls_UrlStr = lnv_CoderObject.UrlEncode(lblb_data)

// above Appeon's example, below what I'd like to do with the result:
inet lnet_base
lnet_base = CREATE n_inet
SetPointer(hourglass!)
lnet_base.HyperlinkToURL( ls_UrlStr )
destroy lnet_base

The above code won't work.


If I don't urlencode my links, they work just fine. It seems the browsers themselves already automatically convert all parts that have to be urlencoded if my url contains any spaces or even "%" in them.

So ... is the urlencode function meant to be used for something else maybe?
Is there another function that would encode a url without changing what doens't need changing when it's a link to an internet address?

regards

Accepted Answer
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Friday, 12 February 2021 04:03 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Miguel,

The UrlEncode() was added to the Coder object so that URLs are encoded in proper format for generating JSON.  Please take a look at the 5-minute mark of this Elevate presentation about the Coder object: https://www.appeon.com/developers/library/videos/encryption-encoding-powerbuilder-2017-r3.html

Best regards,
Armeen

 

Comment
  1. Armeen Mazda @Appeon
  2. Friday, 12 February 2021 04:20 AM UTC
You’re very welcome.
  1. Helpful
  1. Miguel Leeuwe
  2. Sunday, 4 July 2021 00:02 AM UTC
FWIW:

In addition, referring to this recent post: https://community.appeon.com/index.php/qna/q-a/replace-spaces-with-20-so-i-can-view-link-in-browser , HyperLinkToUrl fails when the link starts with "file:///...."; and when that url contains spaces.

The solution is to enclose the url with outer single quotes and the inner string with double quotes.

regards.
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Sunday, 4 July 2021 03:21 AM UTC
Thanks for sharing!
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.