Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

encode string to URL

Hi All,

I need to convert strings to be URI conform. That means replacing spaces by %20 and so on. Before I go back writing nested Replace statements, I wondered if there is something like an encodeURI() function? I haven't found anything similiar, but any hint or help is highly appreciated.

Thank you!

Florian

1 Solution

Accepted Solutions
Not applicable
Author

After looking around a while I believe there is no such function

View solution in original post

4 Replies
Not applicable
Author

After looking around a while I believe there is no such function

Not applicable
Author

So I began to write some little "parser". Feel free to add your comments and ideas:

CharMap:

LOAD * INLINE [

Char, ASCII

" ", %20

(, %28

), %29

., %2E

-, %2D

ß, ss

ä, ae

ö, oe

ü, ue

Ä, Ae

Ö, Oe

Ü, Ue

];

Sub URIencoder(txt)

LET recNo = 1;

DO WHILE recNo < FieldValueCount('Char') + 1;

LET from = FieldValue('Char', $(recNo));

LET to = FieldValue('ASCII', $(recNo));

LET txt = Replace('$(txt)', '$(from)', '$(to)');

LET recNo = recNo + 1;

LOOP

End Sub

DROP TABLE CharMap;



rbecher
MVP
MVP

Hi Florian,

I think the right way is using Jscript encodeURI function because there are endless of UTF chars especially if you have to deal with web sources ans URL parameters (like Twitter):

This is an example for a Jscript macro code in QV:

function encode (uri){

          return encodeURI(uri);

};

- Ralf

Astrato.io Head of R&D
rbecher
MVP
MVP

Btw. there is a new solution I found to load a full encoding list and use it with MapSubString():

String manipulation

Astrato.io Head of R&D