The characters c("&", '"', "'", "<", ">") will be replaced with c("&amp;", "&quot;", "&#039;", "&lt;", "&gt;"), respectively.

htmlspecialchars(string)

Arguments

string

the string with (or w/o) HTML special chars

Value

the string with special chars replaced.

See also

Examples

htmlspecialchars("<a href = 'https://yihui.org'>Yihui</a>")
#> [1] "&lt;a href = &#039;https://yihui.org&#039;&gt;Yihui&lt;/a&gt;"
# &lt;a href = &#039;https://yihui.org&#039;&gt;Yihui&lt;/a&gt;