Here is the code showing the problem:
myPath = getwd()
cat(\"abcd\", append = T, file =paste(myPath,\"temp1.html\", sep = \"\\\\\")) # This is fine
cat(\"
The problem isn’t with R (R is correctly producing UTF-8 encoded output) … it’s just that your web browser assumes the wrong encoding in the absence of an explicitly specified encoding. Just use the following snippet (from inside R) instead:
שלום
This specifies a correct encoding (UTF-8), and hence causes the browser to thread the following text correctly.