Url Encoding

Discussions specific to Team Developer 5.2.

Url Encoding

Postby ITOU » Wed Jul 08, 2015 7:19 am


Is there any function in Team Developer 5.2 that can be used to URL encode a string (like encodeURI() in JavaScript ) ?

I would like to send sms from Team Developer 5.2 and the URLs often contain characters outside the ASCII set, so the URL has to be converted into a valid ASCII format.

For example I would like to convert "This is a test message \n with various characters: ¿ñüÄÑà. Κείμενο. &*@"
to "This%20is%20a%20test%20message%20%5Cn%20with%20various%20characters%3A%20%C2%BF%C3%B1%C3%BC%C3%84%C3%91%C3%A0.%20%CE%9A%CE%B5%CE%AF%CE%BC%CE%B5%CE%BD%CE%BF.%20%26*%40"

I would appreciate any information.

Posts: 6
Joined: Mon Jan 25, 2010 1:15 am

Re: Url Encoding

Postby wardies » Thu Jul 09, 2015 9:43 am

None that I am aware of.

You could roll your own, using Rosetta Code as your guide.

Or you could make use of the C (remember to compile as Unicode) or C# examples there; TD provides good interoperability with both, though this might be overkill.
User avatar
Posts: 86
Joined: Thu Feb 14, 2008 3:34 am

Re: Url Encoding

Postby Jeff @ PC Design » Thu Jul 09, 2015 4:30 pm

Westies has a good suggestion about 'rolling your own.' I'd thought of the same thing. Basically:
* define a lookup class with inst. vars. like this:
- decimal value
- formatted HEX value as single or double values as you show
- the char for this HEX value.
you'd use your input string char. to search for a match and return the formatted HEX value.

I'll attach a zip of a TD v5.2 test that pops. a TW up to the last Cyrillic char and includes the Greek chars.

What I'm a bit confused about, though, is how you get %CE for the start of the Greek double-wide chars. According to this site and my test case, first word is %03, as shown here: http://symbolcodes.tlt.psu.edu/bylangua ... chart.html

And if you run my test, the 'μ' (micro) char is %03%BC, as shown in that Greek chart page just above. Anyway, this might be a start for you. I did start a TW menu called 'ReturnHexString!' that would build the output HEX string based on a sTestChars = 'Κείμενο' set of test chars after a scan of the TW for each char. But didn't get that far and figured a better way to test this is actually create a class to manage the black box of input: string and output: HEX string.

As always, I recommend you putting a test together and/or mod. mine and see if you can get what you want to work. If not, post what you have.

(There also the chance that TD can't generate a correct char. for some of the high double-byte numbers. You might need to find a web page with the chars displayed and write a short parsing appl. to pull out the correct char. for each HEX value.)

OTOH, I didn't do any searching that Wardies suggested, other than look at the Rosetta page, so maybe there's something more canned (ActiveX control, DLL, etc.)
You do not have the required permissions to view the files attached to this post.
Jeff Luther/PC Design http://www.jeffluther.net/TD/
Come join us at Dave Rabelink's "Team Dev. Community Forum".
All TD, TDMobile & SQLBase users welcome!
Jeff @ PC Design
Posts: 206
Joined: Fri Feb 08, 2013 2:40 pm
Location: Palm Springs, California

Re: Url Encoding

Postby ITOU » Mon Jul 13, 2015 6:45 am

Thank you very much wardies- and Jeff for the answers!!

Best regards,
Posts: 6
Joined: Mon Jan 25, 2010 1:15 am

Return to Team Developer 5.2

Who is online

Users browsing this forum: No registered users and 2 guests