Encodes special characters in a string to their corresponding HTML entities.
The string to encode.
Whether to truncate whitespace.
The encoded string.
Encodes special characters in a string to their corresponding HTML entities.