Shiny renderText: Unicode characters not displayed correctly

,

Hi,
Below is a minimal Shiny app to demonstrate the issue I'm having. I'm trying to display Unicode characters in Shiny, specifically the Intersection symbol \U22C2. As you can see if you run the app code, this symbol displays correctly in the label for a set of radio buttons, but does not display correctly in renderText, even though if I copy the renderText contents into a "cat()" call it displays correctly in my console. renderText() displays it as "<U+22C2>".

The rendering of \u2264 is even worse! It should be less than or equals to symbol, and instead it's displayed as "="!

What can I do to get this to display correctly? It shows up incorrectly in my Rstudio built-in browser for Shiny and in Firefox v126, both on Windows 10.

Thanks.

cat("\U22c2")
library(shiny)

ui <- fluidPage(

    textOutput("temp1"),
    textOutput("temp2"),
    textOutput("temp3"),
    textOutput("temp4"),
    textOutput("temp5"),
    radioButtons("radio","\U22C2",choices=c("Test"))
)

server <- function(input, output) {

    # output$temp1 <- renderText({intToUtf8(as.integer("0x22c2"))})
    # output$temp1 <- renderText({enc2utf8("\U22c2")})
    output$temp2 <- renderText({"\U22c2"})
    output$temp3 <- renderText({"&#x3B4"})
    output$temp4 <- renderText({"\u2264"})
    output$temp5 <- renderText({"basic text"})
}

# Define server logic required to draw a histogram
server <- function(input, output) {

    output$temp1 <- renderText({intToUtf8(as.integer("0x22c2"))})
    output$temp2 <- renderText({"\U22c2"})
    output$temp3 <- renderText({"&#x3B4"})
    output$temp4 <- renderText({"basic text"})
}

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

Works fine for me with RStudio and Firefox:

library(shiny)

ui <- fluidPage(
  textOutput("temp1"),
  textOutput("temp2"),
  textOutput("temp3"),
  radioButtons("radio", "radio button label: \U22C2", choices = c("Test"))
)

server <- function(input, output, session) {
  output$temp1 <- renderText({
    "\U22c2"
  })
  output$temp2 <- renderText({
    "\u2264"
  })
  output$temp3 <- renderText({
    "&#x3B4"
  })
}

shinyApp(ui = ui, server = server)

image

image

1 Like

OK, so it works on some systems but not others. But that doesn't help me, because it's not working on my system. What system are you using?

I still need to know what to change on my system to get it to work correctly.

Thanks
Louise

I'm using R version 4.4.0 (2024-04-24 ucrt) -- "Puppy Cup", the latest CRAN version of shiny (1.8.1.1),
RStudio 2024.04.1+748 "Chocolate Cosmos" Release (3ada7c6ddc8fcdb86a727a4f0ae467b9d9a7296c, 2024-05-07) for windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2024.04.1+748 Chrome/120.0.6099.291 Electron/28.2.6 Safari/537.36, Quarto 1.4.553

and the latest Firefox verison (126.0) on a Windows 10 PC.

I'm also not able to reproduce this, unless I mess with the locale on purpose. What does Sys.getlocale() return for you, @LMc?

Hi, Thanks for the info. I can't check right now as I won't be back at my work computer for a couple of days, but it will probably be NZ. I'll let you know when I can.
It's the latest Firefox, 126.0 and Windows 10 Pro.

Hi,

My Sys.getlocale result is as follows:

Sys.getlocale()
[1] "LC_COLLATE=English_New Zealand.1252;LC_CTYPE=English_New Zealand.1252;LC_MONETARY=English_New Zealand.1252;LC_NUMERIC=C;LC_TIME=English_New Zealand.1252"

And my R and RStudio versions were:

version
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 1.1
year 2021
month 08
day 10
svn rev 80725
language R
version.string R version 4.1.1 (2021-08-10)
nickname Kick Things
RStudio 2021.09.0+351 "Ghost Orchid" Release (077589bcad3467ae79f318afe8641a1899a51606, 2021-09-20) for Windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36

I've now switched to v. 2023.12.1 of RStudio and v. 4.4.0 of R and that seems to have solved the problem. So thanks for your help, and please feel free to close this issue now

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.