Vely logo install | documentation | examples | changelog
16.10.0 released May 10, 2023
encode-web

Purpose: Web(HTML)-encode string.

encode-web <string> to [ define ] <encoded string> \
    [ output-length [ define ] <encoded length> ] \
    [ input-length <length> ]

encode-web encodes <string> so it can be used in a HTML-like markup text (such as a web page or an XML/XHTML document), and stores the result in <encoded string> which may be created with optional "define". <encoded string> is allocated memory.

Optional "output-length" clause lets you get the length of the encoded string in <encoded length>, which can be created with optional "define". You can encode only the first <length> bytes, given by an "input-length" clause.
Examples
In this example, a string "str" will be web-encoded and the result is in "result" variable, with its length in "len_of_result" variable:
char str[]="  x<y>z&\"'  ";
encode-web str to define result output-length define len_of_result

The "result" is "   x&lt;y&gt;z&amp;&quot;&apos;  " and "len_of_result" is 33.
See also
Web encoding ( decode-web   encode-web  )  SEE ALL (documentation)


Copyright (c) 2017-2023 Dasoftver LLC