How can I change the default encoding when sourcing?


#1

image
A while ago, a window pop up asking me the default encoding for sourcing, and I selected UTF-8. Now everytime when I source a file, there is "encoding = 'UTF-8'" in the function, and it cause errors.
So how can I reset this? There is no "encoding = 'UTF-8'" in the function before I changed that setting. BTW, it seems there is no such settings in global options.


#2

Go to RStudio >> Preferences and select Code. From there select the Saving tab from the top (see below)

When you click on Change... a prompt will open that allows you to either select a different default encoding, or select "[Ask]" to choose an encoding each time:


#3

Thanks, but that won't work.
Anyway I've reinstalled rstudio, and it's solved.


#4

If your question's been answered (even if by you), would you mind choosing or marking a solution? (See FAQ below for how).

Having questions checked as resolved makes it a bit easier to navigate the site visually and see which threads still need help. It also saves someone from spending time to respond to a problem that you've already resolved.