16

I'm working with RStudio Version 0.98.507. Short Info about initial working instruments:

R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

other attached packages:
[1] shinyapps_0.3.53 RJSONIO_1.2-0.2  shiny_0.9.1.9013

loaded via a namespace (and not attached):
 [1] bitops_1.0-6    Cairo_1.5-5     caTools_1.17    digest_0.6.4   
 [5] htmltools_0.2.4 httpuv_1.3.0    Rcpp_0.11.1     RCurl_1.95-4.1 
 [9] shinysky_0.1.2  tools_3.1.0     xtable_1.7-3   

I have a problem by deploying my shiny app on the shiny server. The problem was at some point solved, but after it appears again. Now I cannot fix it any more. My problem are the german letters in helpers.R. Unfortunately, I cannot avoid using them. I'm sourcing my help scrpits helpers.R into server.R like it is shown and taught in Shiny Tutorial. All my R-scripts are carefully saved under UTF-8 format. I cannot use the command

options(encoding="UTF-8")

because after executing it, the command deployApp("app") doesn't work. I set location using

Sys.setlocale(category = "LC_ALL", locale = "German")

It also doesn't work. I cannot understand, why the letters in mainPanel and sidebarLayout are readable, but those from helpers.R not. Can someone help me to solve this paradox?

EXAMPLE

ui.R

library(shiny)

shinyUI(fluidPage(withMathJax(),
                  titlePanel("Währung"),

                  sidebarLayout(position="right",
                                sidebarPanel(
                                        h5("Bedienfenster"),
                                        sliderInput('x', 'x axis',
                                                    value=50, min=3, max=150, step=1,)
                                ),

                                mainPanel(
                                        plotOutput("Plot")
                                )
                  )
))  

server.R

shinyServer(function(input, output){
        output$Plot <- renderPlot({
               x <- rnorm(input$x)
               hist(x, main="", xlab="", ylab="")
               title(main="Schätzgerade", xlab="Währung", ylab="Dichte")
        })
})

After deploying I get following app.

And_R
  • 1,647
  • 3
  • 18
  • 32
  • 1
    Did you try setting the `encoding=` parameter in the `source()` command? – MrFlick Jun 21 '14 at 18:12
  • Of course, it has the same effect like `opitions(encoding="UTF-8")` – And_R Jun 21 '14 at 19:07
  • 1
    Well then it to doesn't seem that your description of the problem is sufficient to make it reproducible for others. That will make it very difficult to help you further. Can you put together a minimal working example that someone else could run to experience the same behavior? – MrFlick Jun 21 '14 at 19:12
  • One more thing maybe which can be helpful, by using encoding="UTF-8" inside of `source` I get the following error `The application unexpectedly exited. **Diagnostic information has been dumped to the JavaScript error console** – And_R Jun 21 '14 at 19:15
  • any Idea how to solve my problem? – And_R Jun 21 '14 at 22:53
  • 1
    This is very likely to be a regression bug of ShinyApps.io, and we are aware of it. Stay tuned for the fix :) – Yihui Xie Jun 21 '14 at 23:17
  • 1
    I work in Linux and fixed some encoding problems changing my locale parameters, `$sudo update-locale LANGUAGE=es_ES:es` (in my case I use spanish accents). If you are using Linux, check your current locale pareameters with `$locale` and give it a try. – Rufo Jun 23 '14 at 11:46
  • Unfortunately, I'm not using linux. But I'll try on linux, too. Thanks for advice. But how to fixthis in Windows, remains still a problem. – And_R Jun 23 '14 at 13:45
  • As of today, the link to the app https://stepanyan.shinyapps.io/Umlaut/ is broken: The page is not found. – Uwe May 10 '19 at 08:57

3 Answers3

13

As a workaround (which I haven't tested), have you tried using escaped Unicode characters, such as "W\u00E4hrung" instead of "Währung"? You can can find details of how to do this with ?Quotes, and there is a list of Unicode characters at http://en.wikipedia.org/wiki/List_of_Unicode_characters.

James Trimble
  • 1,868
  • 13
  • 20
3

What work for me is to change the encoding of the file (in Rstudio File>Reopen open with encoding) and set encoding:

  • UTF-8 for ui.R
  • WINDOWS-1252 for server.R and global.R

I do not know the reason but it made the trick for me.

pau.ferrer
  • 553
  • 1
  • 6
  • 14
  • This will not work when shiny 0.10.1 is released (hopefully in a few days). These R scripts must be encoded in UTF-8. – Yihui Xie Jul 23 '14 at 18:18
2

Shiny 0.10.1 has been released on CRAN, so just install.packages('shiny'). Please ignore the answer below.


We have not really started working on the Unicode issue under Windows until recently. Now the problem should be solved, and you can try to install the latest development version from here:

devtools::install_github('rstudio/shiny')

We plan to ship it in shiny 0.10.1 to be released soon, so we will appreciate it if you can help us test it. Basically all you need to do is to make sure ui.R and server.R are encoded in UTF-8. You do not need to set options(encoding = 'UTF-8') or escape ä as \u00E4.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419