【发布时间】:2017-10-04 17:02:14
【问题描述】:
我有一个 Shiny 应用程序,它在我的 Windows10 上本地运行良好,但是当部署到 shinyapps.io 时,数据中的 Ä、ü 等德语字符显示不正确。
数据从 R 中保存为 csv:
test <- data.frame(a = "Für", b = 1)
write.csv2(test, file = "data.csv", row.names = FALSE)
这是一个简单的示例应用:
global.R
library(shiny)
data <- read.csv2("data.csv", stringsAsFactors = FALSE)
ui.R
ui <- fluidPage(
textOutput("text")
)
服务器.R
server <- function(input, output, session) {
output$text <- renderText(data$a)
}
我也试过read.csv2(..., encoding = "utf8"),这并没有改变任何东西。 ui.R、server.R、global.R都保存为utf8。
有人知道解决方案吗?
谢谢。
【问题讨论】:
-
原文件呢,能证明是UTF-8吗?你试过
UTF-8(注意大小写)吗? -
没有。在哪里可以查看 csv 文件的编码? UTF-8 不起作用
-
我试过
encoding = "latin1",然后Ä显示为ü -
我一般用记事本++。