I need that in the input of a sentence, I identify that if I have any emoji in that sentence I need to decode the emoji to a string, I did it this way but it is not working. Does anyone know how to help me please?
@emoji_ 127_462
@ascii 88
def decode(sentence) when is_nil(sentence), do: sentence
def decode(sentence) do
replace_emoji(sentence)
end
defp replace_emoji(decode) do
char = to_charlist(decode)
Enum.map(charlist, fn a -> emoji_into_string(a) end) |> to_string()
end
def emoji_into_string(c) do
if c > @emoji_ do
@ascii
else
c
end
end
Why not break apart the string by using String.codepoints and then iterate on each character? I wouldnât rely on to_charlist to do the same thing properly (but I might be wrong).
Can you give us an example of a string with which your code doesnât return what you expect?
First, thanks for the feedback, I didnât realize that it doesnât make my text clear.
The following is:
I need a function that, when receiving an input that has an emoji, can decode it to a text: example
Input: âtest â
Output: âtest :grinningâ
First, thanks for the feedback, I didnât realize that it doesnât make my text clear.
The following is:
I need a function that, when receiving an input that has an emoji, can decode it to a text: example
Input: âtest â
Output: âtest :grinningâ
Can you go through the instructions in the link @kip provided:
If you have any specific question after trying out - may be you can post saying âI tried this and I am having specific problem doing this step or invoking this functionâ?