воскресенье, 16 января 2005 г.

Hex and URL reserved words

Hex and URL reserved wordsl

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,

http://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:
http://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("&"))

Комментариев нет: