“If your business depends on you, you don't own a business--you have a job. And it's the worst job in the world because you're working for a lunatic!”
by Michael E. Gerber The E-Myth (Revisited)

Snippet: HTML Encode

This snippet will ensure that text will store inside “markup” languages (i.e. HTML and XML). Nothing elegant… but highly useful. ;)

Click here to download the snippet: HTML Encode

Sample Input:
<Sample>Some common text & such. Lance really likes using the · symbol in S·O·S, doesn’t he?</Sample>

Sample Output:
&lt;Sample&gt;Some common text &amp; such. Lance really likes using the &#183; symbol in S&#183;O&#183;S, doesn’t he?&lt;/Sample&gt;

Leave a Reply

Tags
Get a free book about code review best practices.