StringTools - Maple Programming Help

Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Encodings : StringTools/EncodeEntities

StringTools

 EncodeEntities
 convert UTF-8 special characters to HTML entities in a string

 Calling Sequence EncodeEntities( s )

Parameters

 s - string; Maple string

Description

 • The EncodeEntities(s) command converts UTF-8 special characters in the input string s to HTML entities.
 • The conversion always uses the hex code form of an entity even when a named entity exists. For example, the pi character will be converted to "π" rather than "π". The form argument defaults to xml, which specifies
 • This command only deals with UTF-8 to Unicode conversions, and does not look at escaping one-byte characters like angle brackets. The StringTools:-Escape command handles this conversion if needed.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $r≔\mathrm{DecodeEntities}\left("エンコード"\right)$
 ${r}{≔}{"エンコード"}$ (1)
 > $r≔\mathrm{EncodeEntities}\left(r\right):$$\mathrm{lprint}\left(r\right)$
 "エンコード"
 > $\mathrm{pichar}≔\mathrm{DecodeEntities}\left("\pi "\right)$
 ${\mathrm{pichar}}{≔}{"\pi "}$ (2)
 > $r≔\mathrm{EncodeEntities}\left(\mathrm{cat}\left("Is",\mathrm{pichar},"> 3.14"\right)\right):$$\mathrm{lprint}\left(r\right)$
 "Is π > 3.14"

Compatibility

 • The StringTools[EncodeEntities] command was introduced in Maple 2018.
 • For more information on Maple 2018 changes, see Updates in Maple 2018.