Tech Tip: Utility method for converting a character to an HTML Entity Number
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: September 19, 2022
In an HTML file, some characters must be added as HTML Entity Name or Entity Number for the Web renderer to display the character correctly.
The following utility method provides a quick way to convert a character to an HTML Entity Number.
// Method: char2HtmlEntityNumber #DECLARE($char : Text)->$htmlEntityNumber_t : Text If (Length($char)=1) $htmlEntityNumber_t:=""+String(Character code($char))+";" End if |
For example:
$htmlEN_t:=char2HtmlEntityNumber("<") // < $htmlEN_t:=char2HtmlEntityNumber("&") // & $htmlEN_t:=char2HtmlEntityNumber("$") // $ |