Emoji problem : replace_emoji function problem

Hi,
I'm trying to convert the emojis in my document to text.
Here is an example :

text=C'est juste enorme ce son <U+0001F44C><U+0001F44C>
tt<- iconv(text, from ="latin1", to = "ASCII", sub = "byte")
replace_emoji(tt)
"C'est juste enorme ce son <U+0001F44C><U+0001F44C>"

Apparently, it didn't work! Could anyone help me to solve this problem, please?
Bests

Any solution plz?
text=C'est juste enorme ce son <U+0001F44C><U+0001F44C>
tt<- iconv(text, from ="latin1", to = "ASCII", sub = "byte")
replace_emoji(tt)
"C'est juste enorme ce son <U+0001F44C><U+0001F44C>"

Apparently, it didn't work! Could anyone help me to solve t

What is replace_emoji ?

Can you provide a reprex ?

Hi,

replace_emoji function replaces emojis with word equivalents

library(textclean)

library(sentimentr)

text=C'est juste enorme ce son <U+0001F44C><U+0001F44C>

tt<- iconv(text, from ="latin1", to = "ASCII", sub = "byte")
replace_emoji(tt)
"C'est juste enorme ce son <U+0001F44C><U+0001F44C>"

Hi,

replace_emoji function replaces emojis with word equivalents

library(textclean)

library(sentimentr)

text=C'est juste enorme ce son <U+0001F44C><U+0001F44C>

tt<- iconv(text, from ="latin1", to = "ASCII", sub = "byte")
replace_emoji(tt)
"C'est juste enorme ce son <U+0001F44C><U+0001F44C>"

I don't know where your source text came from but using another syntax for your UTF8 char it works

text="C'est juste enorme ce son \U0001F44C\U0001F44C>"
textclean::replace_emoji(text)
#> [1] "C'est juste enorme ce son OK hand OK hand >"

# You could convert from the <U+ > form
text2 <- "C'est juste enorme ce son <U+0001F44C><U+0001F44C>"
text2 <- gsub("<U\\+([A-Z0-9]+)>", "\\\\U\\1", text2)
textclean::replace_emoji(stringi::stri_unescape_unicode(text2))
#> [1] "C'est juste enorme ce son OK hand OK hand "

Created on 2020-04-11 by the reprex package (v0.3.0.9001)

Hope it helps

1 Like

It works! Thanks a lot

Best
Z

1 Like

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.