Error saving file with garbled error message

I have encountered with this error message repeatedly today within one r script. The error message is as follows.
image
In order to see the error message I've tried adding language = en to the Rconsole file, and also typing this command Sys.setenv(LANGUAGE='en')
And I tried to set the default text encoding from options to UTF-8.
Still I got the same error message, and I've tried updating, it's not working either.

My session info is as follows.
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936
[2] LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1 yaml_2.1.19

It would be great if someone can help me understand what is going on with this script and how can I get a meaningful error message instead of those messy symbols, and eventually how can I save this script. Right now, I have to paste it to a new script in order to save it. And sometimes it works, sometimes I got the same error message.

We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.


Are you using the official CRAN build of R? We've had some similar reports from users using e.g. an Anaconda installation of R + RStudio -- is that true in your case as well?