Search code examples
iosswiftutf-8emoticons

How to identify UTF-8 encoded text from a string and convert it to smiley\emoticon in Swift


I am doing App which support Smiley/emoticons feature. From the backend I am getting response like this str = "Hferuhggeðððððfjjnjrnjgnejfnsgjen".

This string response has a UTF-8 encoded text in it, for the above str UTF-8 encode text is "ððððð".

Now I need to identify the location of the utf-8 encoded text from the response obtained, and convert that encoded text to an emoticon/smiley.


Solution

  • Finally I found solution if you decode string you will get smiley ,please find the code

     let che = descriptionText.cString(using: .isoLatin1)
     let decode_string = String(cString: che!, encoding: .utf8)
    

    This worked for me.