Decode and Encode HTML Entities
Decode and encode HTML entities.
HTMLdecode(x, named = TRUE, hex = TRUE, decimal = TRUE) HTMLencode(x, use.iconv = FALSE, encode.only = NULL)
x |
a string (character vector of length one) |
use.iconv |
logical. Should conversion via |
named |
logical: replace named character references? |
hex |
logical: replace hexadecimal character references? |
decimal |
logical: replace decimal character references? |
encode.only |
character |
HTMLdecode replaces named, hexadecimal and
decimal character references as defined by
HTML5 (see References) with characters. The
resulting character vector is marked as
UTF-8 (see Encoding).
HTMLencode replaces UTF-8-encoded
substrings with HTML5 named entities
(a.k.a. “named character references”). A
semicolon ‘;’ will not be replaced by
the entity ‘;’. Other than that,
however, HTMLencode is quite thorough in its
job: it will replace all characters for which named
entities exists, even ‘,’ and or
‘?’. You can restrict the
characters to be replaced by specifying encode.only.
character
Enrico Schumann
HTMLdecode(c("Max & Moritz", "4 < 9"))
## [1] "Max & Moritz" "4 < 9"
HTMLencode(c("Max & Moritz", "4 < 9"))
## [1] "Max & Moritz" "4 < 9"
HTMLencode("Max, Moritz & more")
## [1] "Max, Moritz & more"
HTMLencode("Max, Moritz & more", encode.only = c("&", "<", ">"))
## [1] "Max, Moritz & more"Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.