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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758200704, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/Encoding(56): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78