0

I have a dataframe with values in multiple languages.

I'm trying to use it in a leaflet map, but I can't get the encoding to work right.

I realize that the relevant encoding is "UTF-8".

I tried the solution suggested here but it doesn't work for me.

Minimal example code:

options(encoding = "UTF-8")
library(leaflet)

df <- data.frame(
  name = c("Europe", "ხარებაშვილი", "喬治亞"),
  lng = c(40, 40.5, 41),
  lat = c(70, 70, 70)
)

leaflet(data = df) %>% 
  addCircleMarkers(label = ~name, labelOptions = labelOptions(permanent = T))

Minimal example screenshot:

enter image description here

Session Info

R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] leaflet_2.0.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0      digest_0.6.18   later_0.7.5     mime_0.6       
 [5] R6_2.3.0        xtable_1.8-3    jsonlite_1.6    magrittr_1.5   
 [9] promises_1.0.1  tools_3.5.1     htmlwidgets_1.3 crosstalk_1.0.0
[13] shiny_1.2.0     httpuv_1.4.5    yaml_2.2.0      compiler_3.5.1 
[17] htmltools_0.3.6
Yanir Mor
  • 581
  • 3
  • 15
  • 1
    Which version of R and `leaflet` are you using? Running your code as is, I was able to [produce three markers with the correct encoding](https://imgur.com/a/ODAivsY). For reference I have R version 3.5.1 (2018-07-02) and leaflet_2.0.2. – Cristian E. Nuno Dec 21 '18 at 23:55
  • 1
    Thanks @CristianE.Nuno. That's odd - I have the exact same versions of R and leaflet (see session info that I added above). Would you please let me know what is your session info so that I can compare the other components? – Yanir Mor Dec 22 '18 at 07:53
  • 1
    Session info was too long to post as a comment so here's a screenshot: https://imgur.com/a/vkiC3nd. – Cristian E. Nuno Dec 22 '18 at 18:41
  • 1
    Thanks again @CristianE.Nuno. Now I'm quite sure it is related to Windows, the locale `en_US.UTF-8` is not available for me... – Yanir Mor Dec 23 '18 at 13:40
  • No problem @yanirmor. I hope you find a solution to your encoding problem. Not sure if this is useful but this might help you download the UTF-8 locale: https://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue. – Cristian E. Nuno Dec 23 '18 at 18:59

0 Answers0