Closed tdhock closed 1 year ago
This could be a bug in base R. Here is a minimal reproducible example:
x = '\U0001F60E abc'
m = gregexpr('a', x)
regmatches(x, m)
It should return 'a'
, but returns 'b'
instead; m
should start from 3 instead of 4. I can work around it by using perl = TRUE
in gregexpr()
. I'm not sure if it's worth reporting this problem to the R core team.
Should be fixed in the markdown package now:
if (packageVersion('markdown') < '1.6.3')
install.packages('markdown', repos = c('https://rstudio.r-universe.dev', 'https://cloud.r-project.org'))
thanks!
My understanding with Emoji character and more generally multibyte character is that useBytes = TRUE
should be used.
x = '\U0001F60E abc'
m = gregexpr('a', x, useBytes = TRUE)
regmatches(x, m)
#> [[1]]
#> [1] "a"
Not sure it is a bug.
Anyway, using perl =TRUE
is probably an ok change around that.
Thanks! My understanding is that an emoji character is not necessarily one character, which makes it tricky to deal with. I've had some pain with this some time ago in JavaScript.
It seems that R core tends to discourage using useBytes = TRUE
, so I often try to avoid it:
It seems that R core tends to discourage using useBytes = TRUE, so I often try to avoid it:
Oh good to know ! thank you for the blog post
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.
By filing an issue to this repo, I promise that
xfun::session_info('knitr')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr')
.I understand that my issue may be closed if I don't fulfill my promises.
Hi @yihui first of all thanks for this wonderful package, which I find very useful.
I have a package on CRAN that uses VignetteEngine{knitr::knitr} to build a vignette, and it recently started failing CRAN checks with the following message (on windows only). https://cloud.r-project.org/web/checks/check_results_nc.html
The issue seems to happen only on windows, and only if the Rmd file has a code chunk that prints emoji. I expected that it should be possible on windows to render an Rmd that has a code chunk that prints emoji, or at least that there should be a more informative error message, like "Rmd with code chunks that print emoji is not supported on windows, but v1-capture-first.Rmd has a code chunk that prints emoji, please remove."
Based on the error message above and the fact that it only occurs on windows, I suspect that a fix to this vignette builder on your end would entail changing some usage of file.path / backslash separator, to a forward slash.
On my end (user who is trying to build a vignette) a fix is to change VignetteEngine{knitr::knitr} to VignetteEngine{knitr::rmarkdown}.
Code to reproduce issue is below,
The output I got on my system is below,
Thanks again and hope this helps. Toby