Detect if a user has typed an emoji character in UITextView

前端 未结 9 1660
醉话见心
醉话见心 2020-12-05 08:13

I have a UITextView and I need to detect if a user enters an emoji character.

I would think that just checking the unicode value of the newest character would suffic

9条回答
  •  既然无缘
    2020-12-05 09:07

    Well you can detect whether it only has ascii characters using this:

    [myString canBeConvertedToEncoding:NSASCIIStringEncoding];
    

    It will say no if it fails (or has emoji). Then you can do a if else statement that does not allow them to click enter or something.

提交回复
热议问题