Search code examples
character-encodingrstudiolocalediacriticscyrillic

How to fix problem with replacement characters "�" on the panels in RStudio?


I think this is problem one can see using Cyrillic locales; also German, French, Turkish etc where letters can have diacritics - umlauts etc.

In my case, replacement characters appeared in panels when I compiled PDF with knitr and tried to find an unsearchable thing.

I have a cp-1251 character encoding by default.

If you want to see this problem by yourself, you can try to compile an example.

\documentclass [russian]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}

\begin{document}

\title{minimal knittr example in R}
\author {John Doe}
\maketitle

Давайте писать по-русски

<<>>=
set.seed(99) 
k = 1 * rnorm(200,3,2)
mean(k); var(k)
@
the first two of x are \Sexpr{k[1:2]}
\end{document}

For the demonstration of this problem, see pic:

R Studio screenshot

How to fix it?


Solution

  • I tried a lot of things, but a solution was easier, than i could imagine.

    Sys.setenv("LANGUAGE"="EN")
    

    and you can see:

    enter image description here