Reputation: 293
I want to add emoji emoticons to my project. This is for a chat application witch is going to windows phone, IOS, android and a .NET website. The phone recognize the smileys from the UTF-8 string sender to them. C# makes squares 😊😊. My quiestion, is the a way to add the emoticons so the site will see them automatically? Something like a library or implementing them as text? Like it recognizes %C3%AB as ë?
Upvotes: 0
Views: 3973
Reputation: 354446
Strings in .NET are always UTF-16. If you have a byte[]
that contains text in UTF-8, then you first need to convert that into a string (which represents text) by using Encoding.UTF8.GetString(bytes)
. If you have a string containing characters that have been bytes of a UTF-8 string before then you're already past a point where there's an easy recovery. You usually can recover, but it's best not to screw up text in the first place. I don't know your code there, though, so it's hard to give concrete advice.
Another point when squares could appear is lack of font support. Emoji for example have no font support on older operating systems (they are a quite recent addition to Unicode). Windows 8 has a font for them, but older OSes might not. Also you mention a web page – if this a web application where you want to display them, you might try other browsers. Font selection algorithms vary and some might not pick up a suitable font even if one exists (Chrome seems to be worst in this respect).
Upvotes: 3