Skip to content

Windows woes: emojis render inline but not in blocks #7

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

Open
Selbosh opened this issue May 4, 2017 · 1 comment
Open

Windows woes: emojis render inline but not in blocks #7

Selbosh opened this issue May 4, 2017 · 1 comment

Comments

@Selbosh
Copy link

Selbosh commented May 4, 2017

I have no doubt that this problem is due to something further upstream but I don't know exactly what. I have tried saving the Rmd file with every possible encoding.

Minimal working example on Windows

Block emojis:

```{r, collapse = TRUE}
emo::ji('poop')
emo:::emoji_name['poop']
```

And inline: `r emo::ji('poop')`

Returns something that looks like this

Block emojis:

emo::ji('poop')
## <f0><U+009F><U+0092><U+00A9>
emo:::emoji_name['poop']
##                poop 
## "<f0><U+009F><U+0092><U+00A9>"

And inline: 💩


Searching online, the only other report of this issue that I could find, with unicode code points (if that's the correct term) being coerced into angle brackets is here.

I have noticed that the behaviour is different in the console and in knitting Rmd files. If I simply enter the following into the console:

emo:::emoji_name['poop']

then the output is

               poop 
"\xf0\u009f\u0092�" 

but, still in the console,

enc2native(emo:::emoji_name['poop'])

returns

                          poop 
"<f0><U+009F><U+0092><U+00A9>" 

which looks like the Rmarkdown output, above.

So it looks like for block text output Rmarkdown/Knitr is parsing (multi-byte?) unicode characters differently to inline, with the result that on Windows, emo works inline but not in chunks.

@yutannihilation
Copy link

I guess this should be reported to hadley/evaluate, which is used inside knitr.

evaluate:::evaluate_call(expression(emo::ji('poop')), NULL, globalenv(), baseenv())
[[1]]
$src
NULL

attr(,"class")
[1] "source"

[[2]]
[1] "<f0><U+009F><U+0092><U+00A9> \n"

And the bellow is basically the same as what evaluate:::watchout() does. I doubt textConnection() can handle emojis, since it does some text conversion which makes us unhappy...

output <- character()
con <- textConnection("output", "wr", local = TRUE)
capture.output(print(emo::ji('poop')), file = con)
close(con)
output
#> [1] "<f0><U+009F><U+0092><U+00A9> "

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants