I'm coding in R. Let's say that I have the unicode value of an emoji as
wink_emoji <- "\U0001f609"
Or, alternatively, as
wink_emoji <- "U+1f609"
Is there a function that I can use to print the actual emoji character to the console? Like this:
[1] "😉"
How about as its HTML character entity?
[1] "😉"
Furthermore, if I have a string like so:
test <- "This is a test U+1f609 U+1F469 U+200D U+2764 U+FE0F U+200D U+1F48B U+200D U+1F469"
Can I run it through a function to match all of the emojis and return this:
[1] "This is a test 😉👩❤️💋👩"
Use utf8_print
from the utf8
package to print, utf8ToInt
to get the integer value of the code point:
wink_emoji <- "\U0001f609"
utf8::utf8_print(wink_emoji)
#> [1] "😉"
utf8ToInt(wink_emoji)
#> [1] 128521
(Printing emoji only works on MacOS and Linux, not on Windows.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With