title: Encoding errors with shiny app and Russian
body: <p>I try to make shiny dashboard but have some encoding problems with the Russian language. Unfortunately, I need to use Russian because the database has column names in Russian and also clients of the dashboard can use only Russian UI. So, here is the pretty simple code:</p>
  
  <pre><code>library(shiny)
  library(ggplot2)
  load(url("http://s3.amazonaws.com/assets.datacamp.com/production/course_4850/datasets/movies.Rdata"))
  
  # Define UI for application that plots features of movies 
  ui &lt;- fluidPage(
  
    # Sidebar layout with an input and output definitions 
    sidebarLayout(
  
      # Inputs
      sidebarPanel(
  
        # Select variable for y-axis
        selectInput(inputId = "y", 
                    label = "Y-axis:",
                    choices = c("imdb_rating", "imdb_num_votes", "critics_score", "audience_score", "runtime"), 
                    selected = "imdb_rating"),
        # Select variable for x-axis
        selectInput(inputId = "x", 
                    label = "X-axis:",
                    choices = c("imdb_rating", "imdb_num_votes", "critics_score", "audience_score", "runtime"), 
                    selected = "imdb_num_votes")
      ),
  
      # Outputs
      mainPanel(
        plotOutput(outputId = "scatterplot")
      )
    )
  )
  
  # Define server function required to create the scatterplot
  server &lt;- function(input, output) {
  
    # Create scatterplot object the plotOutput function is expecting
    output$scatterplot &lt;- renderPlot({
      ggplot(data = movies, aes_string(x = input$x, y = input$y)) +
        geom_point()
    })
  }
  
  # Create a Shiny app object
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>It works perfectly. But when I add a line with Russian text</p>
  
  <pre><code>print("Русский текст")
  </code></pre>
  
  <p>I recieve error:</p>
  
  <pre><code>Warning in checkEncoding(file) :
    The input file C:/path/test.R does not seem to be encoded in UTF8
  Warning in readLines(file, warn = FALSE) :
    invalid input found on input connection 'C:/path/test.R'
  Error in parse(file, keep.source = FALSE, srcfile = src, encoding = enc) : 
    C:/path/test.R:4:7: unexpected INCOMPLETE_STRING
  3: load(url("http://s3.amazonaws.com/assets.datacamp.com/production/course_4850/datasets/movies.Rdata"))
  4: print("
           ^
  Error in sourceUTF8(fullpath, envir = new.env(parent = globalenv())) : 
    Error sourcing C:\Users\Username\AppData\Local\Temp\RtmpELJQpW\file36805da7570a
  </code></pre>
  
  <p>If I just delete the line</p>
  
  <pre><code>shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>Russian text works correctly, but of course, script doesn't work correctly - shiny app wasn't created.</p>
  
  <p>Also if I add any comment in Russian </p>
  
  <pre><code># Comment in russian: комментарий на русском
  </code></pre>
  
  <p>I see this error:</p>
  
  <pre><code>Warning in checkEncoding(file) :
    The input file C:/path/test.R does not seem to be encoded in UTF8
  Warning in readLines(file, warn = FALSE) :
    invalid input found on input connection 'C:/path/test.R'
  Error in func(fname, ...) : app.R did not return a shiny.appobj object.
  </code></pre>
  
  <p>I tried to save the script in encoding format cp1251, but it didn't help.
  Also I tried this:</p>
  
  <pre><code>Sys.setlocale("LC_ALL","Russian_Russia") 
  </code></pre>
  
  <p>I tried to save script in encoding format utf-8 and it helps for a while... But I opened script at the next day and it was broken again - all Russian symbols are replaced by strange things like "СЂСѓСЃСЃРєРёР№ РєРѕРјРјРµРЅС‚" and errors mentioned above also returned.</p>
  
  <p>Can someone give me an advice what to do with it?</p>