Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: trouble with cyrillic encoding in emayili::render #146

Open
selesnow opened this issue Feb 9, 2023 · 0 comments
Open

[BUG]: trouble with cyrillic encoding in emayili::render #146

selesnow opened this issue Feb 9, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@selesnow
Copy link

selesnow commented Feb 9, 2023

Description of the bug

I have Rmd file with cyrillic (russian language) text. When i try rending (emayili::render()) and send it i get next:

My rending code:

library(emayili)
library(stringr)
library(rmarkdown)

Sys.setlocale(locale = 'russian')

rmarkdown::render(here::here('rmd', 'fb_spend_limit_checker.rmd'), encoding = 'CP1251')

email <- envelope() %>% 
  emayili::render(here::here('rmd', 'fb_spend_limit_checker.html')) %>% 
  from("Netpeak Analytics Dept. <[email protected]>") %>% 
  to(c("[email protected]"))  %>% #, "[email protected]")) %>% 
  subject("Дайджест: Контроль лимита расходов в Facebook аккаунтах за {{format(Sys.Date(), '%d.%m.%Y')}}", interpolate = T)
  
# send mail
smtp <- gmail(Sys.getenv('DEPT_EMAIL'), Sys.getenv('DEPT_EMAIL_PWD'))
smtp(email)

But i can fix it over iconv:

library(emayili)
library(stringr)
library(rmarkdown)

Sys.setlocale(locale = 'russian')

rmarkdown::render(here::here('rmd', 'fb_spend_limit_checker.rmd'), encoding = 'CP1251')

email <- envelope() %>% 
  emayili::render(here::here('rmd', 'fb_spend_limit_checker.html')) %>% 
  from("Netpeak Analytics Dept. <[email protected]>") %>% 
  to(c("[email protected]"))  %>% #, "[email protected]")) %>% 
  subject("Дайджест: Контроль лимита расходов в Facebook аккаунтах за {{format(Sys.Date(), '%d.%m.%Y')}}", interpolate = T)
  
# -------------------------------------------------------------------------->
# -------------------------------------------------------------------------->
# fix encoding
email$parts[[1]]$content <- iconv(email$parts[[1]]$content, from = 'UTF-8', to = '1251') %>% iconv(from = 'UTF-8', to = '1251')
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

# send mail
smtp <- gmail(Sys.getenv('DEPT_EMAIL'), Sys.getenv('DEPT_EMAIL_PWD'))
smtp(email)

My session info

> sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 14393)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=Russian_Russia.1251           LC_MONETARY=English_United States.1252 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] rmarkdown_2.16 stringr_1.4.1  emayili_0.7.13

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9       pillar_1.8.1     compiler_4.2.1   base64enc_0.1-3  tools_4.2.1      digest_0.6.29    evaluate_0.16    lifecycle_1.0.2  tibble_3.1.8    
[10] pkgconfig_2.0.3  rlang_1.0.5      cli_3.4.0        DBI_1.1.3        rstudioapi_0.14  commonmark_1.8.0 curl_4.3.2       xfun_0.32        fastmap_1.1.0   
[19] dplyr_1.0.10     httr_1.4.4       knitr_1.40       xml2_1.3.3       generics_0.1.3   vctrs_0.4.1      triebeard_0.3.0  rprojroot_2.0.3  tidyselect_1.1.2
[28] glue_1.6.2       here_1.0.1       R6_2.5.1         fansi_1.0.3      purrr_0.3.4      tidyr_1.2.1      logger_0.2.2     magrittr_2.0.3   urltools_1.7.3  
[37] htmltools_0.5.3  assertthat_0.2.1 rvest_1.0.3      mime_0.12        utf8_1.2.2       stringi_1.7.8   

Steps To Reproduce

Part of Rmd filr

---
title: "Дайджест контроля лимита трат в Facebook"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Дайджест контроля лимита трат в Facebook}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

Этот дайджест позволяет контролировать установленные лимиты затрат в рекламных аккаунтах Facebook, по проуктам услуги "Пополнение Facebook".

library(kableExtra)
library(tidyr)

df <- data.frame('колонка 1' = c(1,2,3), 'колонка 2' = c(4,5,6))

kbl(df)

Rending code

library(emayili)
library(stringr)
library(rmarkdown)

Sys.setlocale(locale = 'russian')

rmarkdown::render(here::here('rmd', 'fb_spend_limit_checker.rmd'), encoding = 'CP1251')

email <- envelope() %>%
emayili::render(here::here('rmd', 'fb_spend_limit_checker.html')) %>%
from("Netpeak Analytics Dept. [email protected]") %>%
to(c("[email protected]")) %>% #, "[email protected]")) %>%
subject("Дайджест: Контроль лимита расходов в Facebook аккаунтах за {{format(Sys.Date(), '%d.%m.%Y')}}", interpolate = T)

send mail

smtp <- gmail(Sys.getenv('DEPT_EMAIL'), Sys.getenv('DEPT_EMAIL_PWD'))
smtp(email)


### Additional Information

> sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 14393)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=Russian_Russia.1251           LC_MONETARY=English_United States.1252 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] rmarkdown_2.16 stringr_1.4.1  emayili_0.7.13

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9       pillar_1.8.1     compiler_4.2.1   base64enc_0.1-3  tools_4.2.1      digest_0.6.29    evaluate_0.16    lifecycle_1.0.2  tibble_3.1.8    
[10] pkgconfig_2.0.3  rlang_1.0.5      cli_3.4.0        DBI_1.1.3        rstudioapi_0.14  commonmark_1.8.0 curl_4.3.2       xfun_0.32        fastmap_1.1.0   
[19] dplyr_1.0.10     httr_1.4.4       knitr_1.40       xml2_1.3.3       generics_0.1.3   vctrs_0.4.1      triebeard_0.3.0  rprojroot_2.0.3  tidyselect_1.1.2
[28] glue_1.6.2       here_1.0.1       R6_2.5.1         fansi_1.0.3      purrr_0.3.4      tidyr_1.2.1      logger_0.2.2     magrittr_2.0.3   urltools_1.7.3  
[37] htmltools_0.5.3  assertthat_0.2.1 rvest_1.0.3      mime_0.12        utf8_1.2.2       stringi_1.7.8   
@selesnow selesnow added the bug Something isn't working label Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants