Search code examples
rcharacter-encodingshinyshiny-server

Bangla language not work in my Shiny App


In my shiny app I use Bangla Language but it not works. I follow there documentation, save with encoding UTF-8 but its ended with ui.R is not encoded in UTF-8.

This is my minimum skeleton:

shinyUI(fluidPage(

  # Application title
  titlePanel("তথ্যসংগ্রহ"),
    sidebarPanel(
    ),
    mainPanel(
    )
  )
)

Here is my session info:

R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

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

Solution

  • The way I understand it your having trouble viewing the characters correctly? You could try a couple of things.

    You could try forcing the page encoding in shiny to utf-8 by setting the meta charset attribute like:

    shinyUI(fluidPage(
      tags$head(
        tags$script(HTML("
          $('html > head').append('<meta charset=\"UTF-8\"/>');
          # To see where tag ends up 
          $('html > head').append('<meta test=\"Yupp\"/>');
          "))
      ),
      # Application title
      titlePanel("তথ্যসংগ্রহ"),
      sidebarPanel(
      ),
      mainPanel()
    ))
    

    Or you could set the R encoding like:

    options(encoding = 'UTF-8')
    

    Or finally you could try to call Sys.setlocale

    Sys.setlocale("LC_COLLATE","bd_BD")
    

    Unfortunately I can't test this since I can't reproduce the error.