由于编码问题,Shiny 似乎处理带有不正确分音符的文本。
我试过添加 options(encoding="UTF-8")
但没有改善。
例如:我输入 ë 并显示 Î,但在日志文件中显示 {"char":"ë"}
我希望有人偶然发现了同样的问题。
将文本处理为输入的可重现示例。
options(shiny.trace = TRUE) # Print debugging info to console
runApp(list(
ui = pageWithSidebar(
headerPanel("Test input characters"),
sidebarPanel(
textInput("char", "Write character", "")
),
mainPanel()
),
server = function(input, output) {
datasetInput <- reactive({ input$char })
}
))
session 信息()
R 版本 3.0.2 (2013-09-25)
平台:i386-w64-mingw32/i386(32位)
Shiny_0.7.0 并使用 chrome
** Shiny 的痕迹 **
Listening on port 8100
SEND {
"config": {
"workerId": "",
"sessionId": "b32ed6dc994bd484ab4a39cae0903c79"
}
}
RECV {"method":"init","data":{"char":"",".clientdata_pixelratio":1,".clientdata_url_protocol":"http:",".clientdata_url_hostname":"localhost",".clientdata_url_port":"8100",".clientdata_url_pathname":"/",".clientdata_url_search":"",".clientdata_url_hash_initial":"",".clientdata_allowDataUriScheme":true}}
RECV {"method":"update","data":{"char":"ë"}}
更新 在我的 Mac 上探索该应用程序,它没有编码问题。
最佳答案
也许这会有所帮助。您必须从 UTF-8
更改编码至 latin1
.
library(shiny)
options(shiny.trace = TRUE) # Print debugging info to console
runApp(list(
ui = pageWithSidebar(
headerPanel("Test input characters"),
sidebarPanel(
textInput("char", "Write character", "")
),
mainPanel(
textOutput("dsI")
)
),
server = function(input, output) {
datasetInput <- reactive({ aaa=input$char
iconv(aaa, "UTF-8", "latin1") })
output$dsI<-datasetInput
}
))
希望它工作正常!
关于r - Shiny - inputText renderText 与 trema/diaeresis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19815860/