Encoding

Choose an encoder from the target context. StringKit-FP works on string bytes for these operations; it does not choose or validate a character encoding for you.

URI components and HTML forms#

For the input a b+c:

FunctionResultSpace rule
PercentEncodea%20b%2Bcspace becomes %20
FormURLEncodea+b%2Bcspace becomes +
URLEncodea+b%2Bclegacy alias for FormURLEncode

PercentDecode preserves a literal +. FormURLDecode and legacy URLDecode interpret + as a space. Use PercentEncode for URI components and FormURLEncode for application/x-www-form-urlencoded data.

The URL encoding recipe is compiled and checks both output lines.

Hex and Base64#

PairUse whenMalformed input behaviour
HexEncode / HexDecodecompatibility-oriented hexadecimal conversionHexDecode remains permissive and may skip invalid pairs
TryHexDecodeexternal or untrusted hexadecimalreturns False and clears the out string
Encode64 / Decode64Base64 conversionDecode64 returns an empty string on invalid input
TryDecode64external or untrusted Base64returns False and clears the out string

Prefer the Try... forms when an empty decoded result would be ambiguous. See Parsing and Try APIs.

HTML#

HTMLEncode encodes the five essential characters (<, >, &, double quote, and single quote). HTMLDecode reverses the supported common entities. The HTML recipe demonstrates the safe text result.

HTML encoding is for HTML text handling, not a general-purpose JavaScript, CSS, SQL, or URL escaping function.