# Set TeXstudio for Unicode .Rnw files (Sweave)

I tried to run Sweave on a .Rnw file from TeXstudio, but the unicode characters don't show up in the .tex file when I typeset with xelatex.

My user command is /usr/local/bin/Rscript -e "Sweave('%.Rnw', encoding = 'utf8')".

The MWE document is the following.

\documentclass{article}

\begin{document}

<<>>=
1 + 2
@

ɑʃɱɪ àüõ

\end{document}


TeXstudio seems not to call the locale as expected, so it is necessary to set the locale within the user command in TeXstudio:
/usr/local/bin/Rscript -e "Sys.setlocale('LC_ALL', 'en_US.UTF-8'); Sweave('%.Rnw', encoding = 'utf8')"

The Rscript path should be changed according to your OS.