Shiny - inputText renderText with trema / diaeresis

时间:2013-11-06 15:19:08

标签: r shiny

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 })
  }
))

sessionInfo() R版本3.0.2(2013-09-25) 平台:i386-w64-mingw32 / i386(32位) Shiny_0.7.0并使用chrome

**闪亮的痕迹**

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上浏览应用,它没有编码问题。

1 个答案:

答案 0 :(得分:0)

也许这会有所帮助。您必须将编码从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  
  } 
))

希望它工作正常!

相关问题