glue icon indicating copy to clipboard operation
glue copied to clipboard

Korean(UTF-8) encoding breaks when texts provided by `str_glue`

Open su-park opened this issue 3 years ago • 0 comments


Korean(UTF-8) encoding breaks when texts provided by str_glue


Brief description of the problem

  • Korean(UTF-8) encoding breaks (it returns a unicode like string '<U...><U...>') in shiny application operated on docker
  • works properly with docker based on mac; does not with docker based on linux server
  • breaks only and if only when a plot including Korean texts that is provided with function str_glue is ported to plotly
  • Korean texts that is not related to the function str_glue does not break

docker envirionments

FROM rocker/shiny-verse:latest

# system libraries of general use
RUN apt-get update && apt-get install -y \
    sudo \
    pandoc \
    pandoc-citeproc \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libssh2-1-dev

### install R packages required
RUN R -e "install.packages(c('hms','devtools'))"
RUN R -e "devtools::install_version('shiny', version='1.6.0', dependencies=T)"
RUN R -e "devtools::install_version('shinydashboard', version='0.7.1', dependencies=T)"
RUN R -e "devtools::install_version('plotly', version='4.9.4.1', dependencies=T)"
RUN R -e "devtools::install_version('DT', version='0.19', dependencies=T)"
RUN R -e "devtools::install_version('tidyverse', version='1.3.1', dependencies=T)"
RUN R -e "devtools::install_version('data.table', version='1.14.2', dependencies=T)"
RUN R -e "devtools::install_version('scales', version='1.1.1', dependencies=T)"
RUN R -e "devtools::install_version('bdscale', version='2.0.0', dependencies=T)"
RUN R -e "devtools::install_version('hrbrthemes', version='0.8.0', dependencies=T)"
RUN R -e "devtools::install_version('showtext', version='0.9-4', dependencies=T)"
RUN R -e "devtools::install_version('stringi', version='1.7.3', dependencies=T)"

insert reprex here

font_add_google("Nanum Gothic")
showtext_auto()

df
# A tibble: 13 × 4
   col           TRT  CTRL total
   <chr>      <int> <int> <int>
 1 72365    25   152   177
 2 72368    25   143   168
 3 72369    25    54    79
 4 74927    25   151   176
 5 70647    25    93   118
 6 76992    25   111   136
 7 79735    25   106   131
 8 74516    25   161   186
 9 70920    25   125   150
10 78630    25   164   189
11 79495    21   125   146
12 79496    24   145   169
13 70105     0    66    66

p <- df %>%
    ggplot(aes(x = '', y = total, text = str_glue("ID: {col}\n처리군 건수: {TRT}\n전체 건수: {total}"))) +
    geom_boxplot(color = "gray") +
    geom_point(aes(x = '', y = total, color = TRT==0), size = 2.5, position = position_jitterdodge()) +
    scale_color_manual(values = c("#DA135F", "gray")) +
    xlab("") + ylab("") + guides(color = 'none') +
    theme(axis.ticks.x=element_blank(), axis.text.x=element_blank()) +
    theme_ipsum(base_family = "Nanum Gothic")
ggplotly(p, tooltip = c("text")) %>%
    layout(xaxis = list(title = "", visible = TRUE), showlegend = FALSE)

su-park avatar Jan 25 '22 21:01 su-park