html_encoding

How do I encode special characters into HTML encoding?

Some characters have special meanings in HTML, for example < and >. If you want these characters to be displayed in your browser you need to use the HTML encoding for them. For example, instead of < you use &lt;. You may need to convert any ‘special’ characters in a string to be HTML encoded.

Solution 1

The module HTML::Entities provides a simple way of encoding (and decoding) a string:

This program produces the following output:

See also

Scroll to Top