htmlspecialchars: Replace HTML special characters with HTML entities

View source: R/htmlspecialchars.R

htmlspecialcharsR Documentation

Replace HTML special characters with HTML entities

Description

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

Usage

htmlspecialchars(string)

Arguments

string

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

Value

the string with special chars replaced.

Author(s)

Yihui Xie <https://yihui.org>

References

https://www.php.net/manual/en/function.htmlspecialchars.php

See Also

gsub

Examples

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

yihui/fun documentation built on Jan. 28, 2023, 2:29 p.m.