encode

Encodes a string by replacing all characters which need to be escaped with appropriate predefined XML entities.

encode() escapes certain characters (ampersand, quote, apostrophe, less-than and greater-than), and similarly, decode() unescapes them. These functions are provided for convenience only. You do not need to use them when using the std.xml classes, because then all the encoding and decoding will be done for you automatically.

If the string is not modified, the original will be returned.

S
encode
(
S
)
(
S s
)

Parameters

s S

The string to be encoded

Return Value

Type: S

The encoded string

Examples

writefln(encode("a > b")); // writes "a > b"

Meta

Suggestion Box / Bug Report