【问题标题】:Shiny - inputText renderText with trema / diaeresisShiny - inputText renderText with trema / diaeresis
【发布时间】:2013-11-17 21:54:54
【问题描述】:

由于编码问题,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 })
  }
))

会话信息() 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 上探索应用,它没有编码问题。

【问题讨论】:

  • 我得到了和你一样的日志,但是应用程序中的字符渲染是正确的。首先更新到shiny8,但我不确定这是不是这个原因。
  • 已更新到 shiny8,但在我的 windows 机器上没有任何改进。但是,我在我的 Mac 上没有遇到这个问题。

标签: r shiny


【解决方案1】:

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

希望一切顺利!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-28
    • 1970-01-01
    • 1970-01-01
    • 2017-02-20
    • 1970-01-01
    • 2017-06-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多