I'm getting trouble with encoding writing content to file. It's a very simple case, and it's getting my head around for a few days.
I've an R file named teste.R
with the following code:
teste <- function(fileContent, fileName) {
fileConn<-file(fileName)
writeLines(fileContent, fileConn)
close(fileConn)
}
page <- ''
page <- paste(page, 'ãõéç')
teste(page, 'file_.html')
Well, I run this piece of code on R-Studio in two different ways:
1 - I simply run the teste
function on the console.
2 - I run the following command on the console:
source('F:/Dropbox/TESE/Projeto/AnaliseSAA/teste.R')
In both cases I get the same content on the file: ãõéç And so far everything is ok. But, if I open the files on a Browser, I get two different outputs:
1- ãõéç
2- ãõéç
All of this because I'm creating a HTML page to display my analyses made in R, and the pages looks terrible with this wrong encoding.
Thanks.