rstudio显示汉字很好,但闪亮的服务器不是

时间:2017-06-24 09:02:27

标签: r shiny

问题描述

以下是代码:

library(shiny)
library(Ruchardet)

ui <- fluidPage(
   # Application title
   titlePanel("中文测试"),
   textOutput("test")
)

server <- function(input, output) {
  output$test <- renderText({
    # detectFileEncoding: detect the encoding of file
    paste(detectFileEncoding("line.txt"),
          readLines("line.txt"), 
          "人")
  })

}

# Run the application 
shinyApp(ui = ui, server = server)

“line.txt”包含两个中文字符:天地

在rstudio中,点击“运行应用”,它显示效果很好。但是,在闪亮的服务器中,它显示:

中文测试
UTF-8 <e5><a4><a9><e5><9c><b0> <U+4EBA>

其他信息

它在docker容器中运行,中文字体已安装apt-get install fonts-wqy-zenhei。 这是会话信息():

R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS/LAPACK: /usr/lib/libopenblasp-r0.2.19.so

locale:
  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
[4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C             
[7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
  [1] Ruchardet_0.0-3 shiny_1.0.3    

loaded via a namespace (and not attached):
  [1] compiler_3.4.0  R6_2.2.2        htmltools_0.3.6 tools_3.4.0     Rcpp_0.12.11   
[6] jsonlite_1.5    digest_0.6.12   xtable_1.8-2    httpuv_1.3.3    mime_0.5       

0 个答案:

没有答案