I have installed R version 4.4.1 on a new computer (windows 11), and try to run a program that runs without problems on other computers (with R version 4.0.2 and 4.1.0). The problematic part is (anonymized):
sendAnEmail <- function(recipient, tøpic, body="", fil){ email <- envelope()%>% from("someone@gmail.com")%>% to(recipient)%>% subject(tøpic)%>% text_body(content=body, encoding="8bit")%>% attachment(fil1) smtp <- server(host = "smtp.gmail.com", port = 587, username = "someone@gmail.com", password = "somepassword") smtp(email, verbose = FALSE)}
This is contained in a file called "test.r", which I source from console.
I tried sourcing with different encodings end got error message:
source("test.r", encoding="utf-8")
Error in source("test.r") : test.r:3:5: unexpected invalid token2: email <- envelope()%>%3: ^Have also tried, with same result:
source("test.r") source("test.r", encoding="native.enc")eval(parse("test.r", encoding="UTF-8"))source.utf8 <- function(f){ l <- readLines(f, encoding="UTF-8") eval(parse(text=l),envir=.GlobalEnv)}source.utf8("test.r")
And:
Sys.getlocale()
[1] "LC_COLLATE=Norwegian Bokmål_Norway.utf8;LC_CTYPE=Norwegian Bokmål_Norway.utf8;LC_MONETARY=Norwegian Bokmål_Norway.utf8;LC_NUMERIC=C;LC_TIME=Norwegian Bokmål_Norway.utf8"
How can I get this work?