KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Hex and URL reserved words
PRODUCT: 4D | VERSION: 2003.2 | PLATFORM: Mac & Win
Published On: March 4, 2004

If you want to pass reserved characters like the ampersand through a URL, you will have to encode your URL in hex notation.

For example,

https://www.mydomain.com?company=James&Abbot

as in, a company named "James & Abbot"

the ampersand character is a reserved word in URLs, so HTTP will actually split this argument as
company=James
Abbot=

In order to correctly assign company to James&Abbot, your URL should be the following:
https://www.mydomain.com?company=James%26Abbot
where 26H is hexadecimal for ascii character 38 or '&'

The following method named Helper_DecimalToHex will convert a decimal number into a hexadecimal string

C_LONGINT($1)
C_TEXT($0)
$result:=String(($1;"&x")
$0:=(Substring(($result;3)
to use it in URL encoding, you might apply it like so:

` returns '%26'
$encoding:="%"+Helper_DecimalToHex(Ascii("&"))