Search notes:

R function: Encoding

The following example assigns the bytes needed to encode René in latin-1 to the variable name. When name is printed, R assumes that name is encoded in UTF-8. Thus, the name is printed with a »wrong« character.
With Encoding(name)<-, the correct encoding is assigned to the string which causes it to be printed correctly.
# name <- '\x52\x65\x6e\xc3\xa9';
name <- '\x52\x65\x6e\xe9';
name
#
# [1] "Ren\xe9"

Encoding(name) <- 'latin1'
name
#
# [1] "René"
Github repository about-r, path: /functions/Encoding.R

See also

character encoding
Index to (some) R functions

Index