0

I am trying to intercept and replace emoji with a corresponding text. I left the default encoding on the Web API (UTF-8 / UTF-16 respectively).

How can I convert an emoji like to something like U+1F609?

Kris van der Mast
  • 16,343
  • 8
  • 39
  • 61
  • related: http://stackoverflow.com/a/26086479/632407 but for perl. – clt60 Apr 28 '17 at 23:15
  • @jm666 Do you have an example in C#? I'm just suffering with the correct encoding parts and I haven't done Perl since 2000. – Kris van der Mast May 02 '17 at 06:45
  • unfortunately haven't C#. I'm a bash/perl guy and the above is based on perl capabilities. – clt60 May 02 '17 at 08:30
  • @jm666 No worries, all the help is welcome. Thanks for trying. – Kris van der Mast May 02 '17 at 08:35
  • What is the problem you're trying to solve? Emojis are UTF8 and I believe UTF8 is compatible with UTF-18 so there should be no need to escape it. If you want to replace it just do a string.replace("","replacement text") its just a string and should behave like such – Max Carroll Mar 20 '19 at 09:35
  • not clear what you need to do but this article might help https://www.hanselman.com/blog/ConvertingFromAStringRepresentationOfAUnicodeCharacterBackIntoAChar.aspx – Max Carroll Mar 20 '19 at 09:39

2 Answers2

0

Here is something that helped me out, although it is in Perl. But you can encode and decode. This should be what you're looking for: https://metacpan.org/pod/Encode::JP::Emoji

Carl Du Plessis
  • 325
  • 3
  • 6
0

This is quite an old post and even though I'm not on the project anymore I want to still answer with my findings for future reference if someone else has the same problem.

What I ended up doing is to create a dictionary with key the UTF combination of the emoji and as a value the text. One thing as an advice: I made sure the longest UTF combination, some emoji have 4 or even 5, as the first ones as otherwise some emoji never got reached. Totally not a perfect and future proof solution that I was hoping for but it worked for us and it shipped into production where it has been working since 2017.

Kris van der Mast
  • 16,343
  • 8
  • 39
  • 61